Parallel.Foreach loop, inconsistent behavior with explicit throw statement
Created a simple program using Linqpad, where I am throwing an exception explicitly in the Parallel Foreach loop, which ideally shall be caught in the caller as Aggregate Exception , but when I explicitly throw the exception, it sometimes skip out few exceptions on random basis. I am not able to understand the behavior, anyone who can explain: void Main() { try { var intList = new List<int> {1,2,3,4,5,6}; Parallel.ForEach(intList, i => Test1(i)); } catch (AggregateException aggregateException) { foreach (var ex in aggregateException.Flatten().InnerExceptions) { ex.Message.Dump(); } } } public