title: Using ContinueWith with Multiple Tasks
body: <p>This is not behaving quite as I thought it would the need is simple, launch a number of tasks to do operations on an object. One unique object per task. The second part is a <code>ContinueWith</code> when each task reports the results. However, I am not getting a <code>WhenAll</code> type behavior. Hopefully someone can set me straight.</p>
  
  <pre><code>_tasks = new Task&lt;AnalysisResultArgs&gt;[_beansList.Count];
  for (int loopCnt = 0; loopCnt &lt; _beansList.Count; loopCnt++)
  {
      _tasks[loopCnt] = Task&lt;AnalysisResultArgs&gt;.Factory.StartNew(() =&gt;
      {
          return _beansList[loopCnt].Analyze(newBeanData);
      });
      await _tasks[loopCnt].ContinueWith(ReportResults, 
                    TaskContinuationOptions.RunContinuationsAsynchronously)  
      // do some housekeeping when all tasks are complete          
  }
  
  private void ReportResults(Task&lt;AnalysisResultArgs&gt; task)
  {
       /* Do some serial operations
  }
  </code></pre>
  
  <p>It was my understanding that <code>_beansList.Count</code> tasks would be launched and by using <code>await</code> on the <code>ContinueWith</code> the housekeeping work won't execute until all the Tasks have completed. I cannot block, as I need to be sure to be able to throttle the incoming data to prevent way too many tasks waiting to be executed.</p>
  
  <p>Where did I goof, the await actually completes and the housekeeping gets run even though not ALL of the tasks have run to completion.</p>