How to return AggregateException from async method
问题 I got an async method working like an enhanced Task.WhenAll . It takes a bunch of tasks and returns when all are completed. public async Task MyWhenAll(Task[] tasks) { ... await Something(); ... // all tasks are completed if (someTasksFailed) throw ?? } My question is how do I get the method to return a Task looking like the one returned from Task.WhenAll when one or more tasks has failed? If I collect the exceptions and throw an AggregateException it will be wrapped in another