Skip to content

Instantly share code, notes, and snippets.

@Calabonga
Created June 22, 2021 03:08
Show Gist options
  • Save Calabonga/869635aa5dfa9515927eed99fc901340 to your computer and use it in GitHub Desktop.
Save Calabonga/869635aa5dfa9515927eed99fc901340 to your computer and use it in GitHub Desktop.
Task extended version for catching all exceptions when all starts
public class TaskExtended
{
public static async Task<IEnumerable<T>> WhenAll<T>(params Task<T>[] tasks)
{
var allTasks = Task.WhenAll(tasks);
try
{
return await allTasks;
}
catch (Exception)
{
// ignore
}
throw allTasks.Exception ?? throw new Exception("This can't possible happen!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment