Task.WhenAll
A .NET method that returns one task which completes when all the tasks you pass it have completed.
In more detail
Start independent operations first, then await Task.WhenAll once, and their waits overlap instead of adding up. If several fail, await rethrows the first and the task's Exception holds them all.
Example
await Task.WhenAll(DelayAsync(1), DelayAsync(2), DelayAsync(3));Related terms
- Task — The .NET type representing an operation that may still be running and will eventually complete with a result, an exception or cancellation.
- AggregateException — A .NET exception that bundles several exceptions together in its InnerExceptions list.
- async and await — Language keywords for writing code that waits for slow work, such as a network call, without blocking a thread.
Taught in
- Async and Await: Managing Concurrency — Modern .NET Core, C# & Enterprise Microservices