Let's say that I got the following code:
var tasks = BuildTaskList();
try
{
Task.WaitAll(tasks.ToArray());
}
catch (AggregateException exception)
{
}
How do I know which task threw which of the exceptions in exception.InnerExceptions?
You still have the list of Tasks, and each Task has an Exception property. Using that you can figure out which exceptions belong with which Task.
But, if you can, it'd be better to use Task.WhenAll or TaskFactory.ContinueWhenAll than do a blocking Wait.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With