Created
June 22, 2021 03:08
-
-
Save Calabonga/869635aa5dfa9515927eed99fc901340 to your computer and use it in GitHub Desktop.
Task extended version for catching all exceptions when all starts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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