Skip to content

Async method lifetime + FAQ enrichment#53158

Draft
BillWagner wants to merge 1 commit intodotnet:mainfrom
BillWagner:async-aweigh-6
Draft

Async method lifetime + FAQ enrichment#53158
BillWagner wants to merge 1 commit intodotnet:mainfrom
BillWagner:async-aweigh-6

Conversation

@BillWagner
Copy link
Copy Markdown
Member

@BillWagner BillWagner commented Apr 15, 2026

  1. Create keeping-async-methods-alive.md — from "Keeping async methods alive." Covers GC lifetime issues with fire-and-forget async tasks, preventing premature collection.
  2. Decompose remaining Async/Await FAQ content into existing docs:
    • Update consuming-the-task-based-asynchronous-pattern.md with FAQ content about awaitables, ConfigureAwait, SynchronizationContext interaction.
    • Update task-based-asynchronous-pattern-tap.md with FAQ content about async keyword behavior, return types, naming conventions.
    • Update implementing-the-task-based-asynchronous-pattern.md with FAQ content about Task.Start, Task disposal.
  3. Add new article to TOC.

Internal previews

📄 File 🔗 Preview link
docs/navigate/advanced-programming/toc.yml docs/navigate/advanced-programming/toc
docs/standard/asynchronous-programming-patterns/common-async-bugs.md Common async/await bugs
docs/standard/asynchronous-programming-patterns/consuming-the-task-based-asynchronous-pattern.md "Consuming the Task-based Asynchronous Pattern"
docs/standard/asynchronous-programming-patterns/implementing-the-task-based-asynchronous-pattern.md Implementing the Task-based Asynchronous Pattern
docs/standard/asynchronous-programming-patterns/keeping-async-methods-alive.md docs/standard/asynchronous-programming-patterns/keeping-async-methods-alive
docs/standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap.md Task-based asynchronous pattern (TAP) in .NET: Introduction and overview

1. Create `keeping-async-methods-alive.md` — from "Keeping async methods alive." Covers GC lifetime issues with fire-and-forget async tasks, preventing premature collection.
1. Decompose remaining Async/Await FAQ content into **existing** docs:
   - Update `consuming-the-task-based-asynchronous-pattern.md` with FAQ content about awaitables, `ConfigureAwait`, `SynchronizationContext` interaction.
   - Update `task-based-asynchronous-pattern-tap.md` with FAQ content about `async` keyword behavior, return types, naming conventions.
   - Update `implementing-the-task-based-asynchronous-pattern.md` with FAQ content about `Task.Start`, `Task` disposal.
1. Add new article to TOC.

### FAQ: Awaitables, ConfigureAwait, and SynchronizationContext

`await` works with awaitable types, not just <xref:System.Threading.Tasks.Task>. A type is awaitable if it provides a compatible `GetAwaiter` pattern. In most public APIs, return <xref:System.Threading.Tasks.Task>, <xref:System.Threading.Tasks.Task`1>, <xref:System.Threading.Tasks.ValueTask>, or <xref:System.Threading.Tasks.ValueTask`1>, and use custom awaitables only for specialized scenarios.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it provides a compatible GetAwaiter pattern

Reading this as layman rises the question what it that pattern?
Should it get explained, linked to some article, etc.?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants