I have seen an example of AggregateException
on the web and I\'m trying to figure out how it works. I have written a simple example, but my code for some reason
My way to resolve it:
var tasks = new Task[] { DoSomethingAsync(), DoSomethingElseAsync() };
try
{
await Task.WhenAll(tasks).ConfigureAwait(false);
}
catch (AggregateException ex)
{
var flatAgrExs = ex.Flatten().InnerExceptions;
foreach(var agrEx in flatAgrExs)
{
//handle out errors
logger.LogError(agrEx, "Critical Error occurred");
}
}