Async internals in .NET
summary
Explains how C# compiler turns a short async method into a ~130-line state machine, shows that no thread dedicated to running the task (tasks are promises, not threads), and digs into Task, TaskCompletionSource, SynchronizationContext and ValueTask allocation tradeoffs. Demonstrates deadlocks from capturing UI sync context and the rule use async all the way up — never call .Wait()/.Result. Builds a custom task scheduler plus synchronization context to await async void by converting continuations to tasks — the hack works and recovers exceptions.
AI-written summary · about
chapters (6)
- 0:00Start
- 1:13Async internals in .NET
- 5:31Task details
- 22:27State machine
- 34:09Deadlocks
- 41:26Exception handling
related talks
51mAsync Internals in .NET
01h 11mEverything You (Don’t) Want to Know About Async and Await in C#
01h 00mAvoiding common pitfalls with async/await
01h 00mCorrecting Common Async/Await Mistakes in .NET
59mAsynchronous Programming From The Ground Up
57mBack to Basics: Efficient Async and Await
58mBack to Basics: Efficient Async and Await
01h 03mDesigning and rewriting asynchronous tasks from scratch
