title: Azure durable function call activtity function in foreach loop. Is it OK?
body: <p><strong>Is it ok to call activity function in a loop, like this: ?</strong></p>
  
  <pre><code>foreach(var item in items)
  {
      await context.CallActivityWithRetryAsync(....,item,...);
  }
  </code></pre>
  
  <p>expanding on the problem I need to execute 2 activities sequentially inside the loop</p>
  
  <pre><code>var tasks = new List&lt;Task&lt;TypeA&gt;&gt;();
  
  foreach(var item in items)
  {
      var task = context.CallActivityWithRetryAsync(Activity2Name,item,...);
  
      tasks.Add(task);
  
      task.ContinueWith(t =&gt; {
          var innerTask =  context.CallActivityWithRetryAsync(Activity3Name,t.Result,...);
          return innerTask;
      },TaskContinuationOptions.ExecuteSynchronously );
  }
  await Task.WhenAll(tasks);
  </code></pre>
  
  <p>I should maybe add inner tasks to task collection somehow, so await will wait on all tasks. And then get rid of the TaskContinuationOptions.ExecuteSynchronously ?</p>
  
  <p>Above thing works. But I'm not sure if its the right way to go about it.</p>