Skip to main content

Handle Exceptions with Task.WhenAll()

var tasks = Enumerable.Range(0, 10).Select(async _ => await Task.Delay(1000));
var whenAll = Task.WhenAll(tasks);
try
{
  await whenAll;
}
catch {}
if (whenAll.Exception is AggregateException ex)
{
  //Handle Exception
}
  

https://www.youtube.com/watch?v=s_NrqRI7Gnc&t=321s