title: Catching AggregateException
body: <p>I am trying to throw and catch an AggregateException.
  I did not use exceptions very much on C#, but the behaviour I found is a little bit surprising.</p>
  
  <p>My code is:</p>
  
  <pre><code>var numbers = Enumerable.Range(0, 20);
  
  try
  {
      var parallelResult = numbers.AsParallel()
          .Where(i =&gt; IsEven(i));
      parallelResult.ForAll(e =&gt; Console.WriteLine(e));
  
  }
  catch (AggregateException e)
  {
      Console.WriteLine("There was {0} exceptions", e.InnerExceptions.Count());
  }
  </code></pre>
  
  <p>It is calling the function IsEven</p>
  
  <pre><code>private static bool IsEven(int i)
  {
      if (i % 10 == 0)
          throw new AggregateException("i");
      return i % 2 == 0;
  }
  </code></pre>
  
  <p>That throws the AggregateException.</p>
  
  <p>I would expect the code to write every even number in the 0,20 range and "There was 1 exceptions" twice.</p>
  
  <p>What I get is some numbers printed (they are random cause of ForAll) and then the exception is thrown, but not catched and the programs stop.</p>
  
  <p>Am i missing something?</p>