C# async and await: start tasks, don't block, compose with WhenAll
Short answer
Mark a method async and return Task or Task<T>. await waits without blocking the thread. Start independent work first, then combine with Task.WhenAll. [S1]
Pattern
async Task<Breakfast> MakeBreakfastAsync()
{
var eggsTask = FryEggsAsync(2);
var baconTask = FryBaconAsync(3);
await Task.WhenAll(eggsTask, baconTask);
return new Breakfast(await eggsTask, await baconTask);
}
Rules of thumb
awaitfrees the thread while the work finishes. [S1]- Awaiting each task as you create it still runs them one after another; start them first to overlap. [S1]
- Factor a series of steps into a method that returns a task, then compose those tasks. [S1]
- Prefer
WhenAllover.Result/.Wait()on unfinished tasks. [S1] - The same
async/awaitmodel covers I/O-bound and CPU-bound work; CPU work usually goes throughTask.Run. [S2]
Claims
- id: C1 claim: await provides a nonblocking way to start a task. source: S1 evidence: "The await keyword provides a nonblocking way to start a task"
- id: C2 claim: Awaiting sequentially delays starting other tasks. source: S1 evidence: "doesn't start other tasks until the current work completes"
- id: C3 claim: WhenAll completes when every listed task completes. source: S1 evidence: "completes when all the tasks in its argument list are complete"
- id: C4 claim: Async code can model both I/O-bound and CPU-bound work. source: S2 evidence: "for both I/O-bound and CPU-bound scenarios"
- id: C5 claim: CPU-bound async work is typically started on a background thread. source: S2 evidence: "starts an operation on a background thread with the Task.Run method"
Sources
- [S1] Asynchronous programming with async and await. Microsoft Learn. https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/ . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-05.
- [S2] Asynchronous programming scenarios. Microsoft Learn. https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/async-scenarios . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-05.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
Source notice: .NET documentation © Microsoft. Licensed under Creative Commons Attribution 4.0 International (https://github.com/dotnet/docs/blob/main/LICENSE).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn, Asynchronous programming with async and await, CC BY 4.0 (dotnet/docs); Microsoft Learn, Asynchronous programming scenarios, CC BY 4.0 (dotnet/docs).
Cite this
iinventedlight. 2026. "C# async and await: start tasks, don't block, compose with WhenAll." iinventedlight Library, iil:note:w7wdq1s3, version of 2026-11-04. https://iinventedlight.com/library/notes/csharp-async-await/. License: CC-BY-4.0.
@misc{iil_note_w7wdq1s3,
author = {{iinventedlight}},
title = {{C\# async and await: start tasks, don't block, compose with WhenAll}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/csharp-async-await/},
note = {Permanent ID iil:note:w7wdq1s3. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/csharp-async-await.md.