Designing and rewriting asynchronous tasks from scratch
summary
Starts by building a minimal Task and TaskCompletionSource, then adds continuations, a TaskScheduler, and inlining so continuations can run concurrently; implements a state machine and custom TaskAwaiter/TaskBuilder to support async/await; demonstrates boxing and allocation pitfalls and fixes that reduce heap allocations; reproduces ConfigureAwait behavior and explains when ConfigureAwait(true/false) actually matters and why state machine boxing causes duplicate tasks; all code is implemented and runs.
AI-written summary · about
chapters (9)
- 0:00Introduction to async
- 3:00Basic task implementation
- 6:43Implementing continuations
- 14:59Task scheduling and inlining
- 22:41Reimplementing async/await
- 30:13Abstracting awaitables
- 36:15Performance optimizations
- 50:11Context and ConfigureAwait
- 56:50Q&A and conclusion
related talks
55mAsync internals in .NET
59mAsynchronous Programming From The Ground Up
01h 00mAvoiding common pitfalls with async/await
57mAsync programming in .NET: Best practices
01h 00mCorrecting Common Async/Await Mistakes in .NET
58mBack to Basics: Efficient Async and Await
49mCorrecting Common Mistakes in Asynchronous .NET Code
01h 11mEverything You (Don’t) Want to Know About Async and Await in C#
