0

I have three tasks and I called Task.WaitAll(task1,task2,task3) after I started the three tasks.

This program works fine in debug mode. When it turns to release mode, an AggregateException throwed.

I would like to know how can I find the cause of the exception.

Thanks

Singed
  • 93
  • 1
  • 9

1 Answers1

1

You can catch the exception and then print out each of the inner exceptions like so:

try
{
    Task.WaitAll(task1, task2, task3);
}
catch (AggregateException ex)
{
    foreach (Exception exx in ex.Flatten().InnerExceptions)
        Console.WriteLine(exx.Message);
}
Servy
  • 202,030
  • 26
  • 332
  • 449
Singed
  • 93
  • 1
  • 9