← All notes

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

Claims

Sources

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

Permanent ID: iil:note:w7wdq1s3

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.},
}

Markdown

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.