Async .NET
Await results, compose tasks, handle failures, and cooperate with cancellation.
- A task represents completion
Await a result without treating a task as a thread.
Core ideas · 10 min - Sequential dependencies
Await one step before starting work that needs its result.
Core ideas · 10 min - Independent tasks and WhenAll
Start independent operations before awaiting their combined result.
Core ideas · 10 min - Observing async failures
Catch an expected failure around the await that observes it.
Core ideas · 10 min - Passing cancellation
Let the caller own the decision to stop an operation.
Working with data · 10 min - Cancelling an awaited timer
Use a cancellable API instead of polling shared flags.
Working with data · 10 min - Finally and ownership
Run cleanup after asynchronous success or failure.
Working with data · 10 min - Completed tasks
Return an existing result without inventing asynchronous work.
Working with data · 10 min - Asynchronous streams
Consume values as an async producer makes them available.
Putting it together · 10 min - Race a completion
Observe which operation completes without losing the remaining work.
Putting it together · 10 min - Bounded batches
Limit outstanding work instead of starting every task at once.
Putting it together · 10 min - Async composition with results
Keep validation synchronous and waiting asynchronous.
Putting it together · 10 min - Execution before the first incomplete await
Observe exactly when an async method gives control back to its caller.
Deeper practice · 18 min - Synchronous guards and faulted tasks
Distinguish a rejected call from a task that represents a failed operation.
Deeper practice · 18 min - Inspecting all failures from WhenAll
Await the group and retain its aggregate diagnostic information.
Deeper practice · 18 min - WhenAny returns a winner that may have failed
Observe the winning task rather than treating race completion as operation success.
Deeper practice · 18 min - Canceling a wait without canceling its operation
Keep the original task when a caller stops waiting early.
Deeper practice · 18 min - Linked tokens combine cancellation owners
Allow either parent lifetime to request cooperative cancellation.
Deeper practice · 18 min - Canceled tasks are distinct from faulted tasks
Inspect terminal states without treating cooperative cancellation as an ordinary error.
Deeper practice · 18 min - Timeouts and caller cancellation are different outcomes
Use a timeout for the wait without pretending the underlying operation stopped.
Deeper practice · 18 min - Bounded async access with SemaphoreSlim
Limit active operations without blocking a thread for each waiting task.
Applied techniques · 18 min - TaskCompletionSource bridges a completion signal
Represent one externally supplied result and reject duplicate completion safely.
Applied techniques · 18 min - ValueTask for a frequently synchronous result
Understand the consumption contract before choosing a lower-allocation return shape.
Applied techniques · 18 min - Asynchronous disposal with await using
Await cleanup before the owning scope reports completion.
Applied techniques · 18 min - Cancellation through async enumeration
Pass a consumer token into an async iterator and stop between elements.
Applied techniques · 18 min - Progress is a reporting contract
Report intermediate state without confusing it with the final result.
Applied techniques · 18 min - Bounded retries for explicitly transient failures
Retry a narrow failure category while keeping attempt limits visible.
Applied techniques · 18 min - Sharing one cached asynchronous operation
Cache the task when callers should observe the same in-flight work.
Applied techniques · 18 min