title: How do I unfold an AggregateException into individual exceptions?
body: <p>It seems like I am getting threading errors as a result of an inconsistent state of my <code>IEnumerable</code>.  Specifically, <code>List&lt;T&gt;</code>.</p>
  
  <p>Here's my workflow:</p>
  
  <pre><code>List&lt;string&gt; IDs = getIDs();
  RunTask(IDs);
  RunTask(IDs);
  
  public void RunTask(List&lt;string&gt; IDs)
  {
      TaskScheduler scheduler = new TaskScheduler();
      TaskFactory factory = new TaskFactory(scheduler);
      var tasks = IDs.Select(name =&gt; factory.StartNew(() =&gt; action(name))).ToArray();
      Task.WaitAll(tasks);
  }
  </code></pre>
  
  <p>I am getting a generic error on my <code>WaitAll()</code> call.</p>
  
  <p>My thinking is that I am getting some sort of unsynchronized IEnumerator, and that I need to make a copy of my <code>List</code> via <code>Array.CopyTo()</code>, then pass it into my multiple threads.</p>
  
  <p>This is my exception:</p>
  
  <pre><code>Error: One or more errors occurred.
  One or more errors occurred.
  at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
  at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)
  at System.Threading.Tasks.Task.WaitAll(Task[] tasks)
  </code></pre>
  
  <p>Any thoughts on this matter?</p>