Async Internals in .NET
summary
Explains how await targets awaiters not necessarily Task objects, shows the compiler‑generated state machine and how synchronization context capture causes continuations to post back (UI thread, ASP request, or thread pool), and demonstrates deadlocks from synchronous .Wait/.Result and fixes with ConfigureAwait(false). Covers Task vs ValueTask allocations, unobserved exceptions, and implements a custom TaskScheduler + synchronization context to await async void — a demo that surfaces async exceptions without crashing the process.
AI-written summary · about
chapters (15)
- 0:00Introduction to async internals
- 1:12Counter intuitive async execution
- 3:18Awaiting without tasks
- 5:46Task lifecycle and implementation
- 10:04Task scheduler internals
- 13:56Task cleanup and ValueTask
- 15:40Synchronization context explained
- 20:17State machine compilation
- 23:47MoveNext method breakdown
- 31:58Deadlock scenarios
- 37:20Unit tests and sync context
- 38:49Exception handling in async
- 41:58Awaiting async void methods
- 44:48Best practices summary
- 46:30Q&A session
related talks
55mAsync internals in .NET
01h 11mEverything You (Don’t) Want to Know About Async and Await in C#
01h 00mAvoiding common pitfalls with async/await
57mBack to Basics: Efficient Async and Await
59mAsynchronous Programming From The Ground Up
58mBack to Basics: Efficient Async and Await
01h 00mCorrecting Common Async/Await Mistakes in .NET
57mAsync programming in .NET: Best practices
