Correcting Common Async/Await Mistakes in .NET 8
summary
Explains how the C# compiler turns each async method into a state-machine class that wraps MoveNext in a try/catch, so unawaited Tasks silently lose exceptions; demonstrates a safe fire‑and‑forget extension (safe fire and forget) used in production (NuGet >1,000,000 downloads) to capture those exceptions. Shows specific refactors: use ConfigureAwait(false) to avoid UI-thread switches, prefer ValueTask for hot paths, use IAsyncEnumerable + Task.WhenAny to parallelize 50–100 API calls, and avoid Task.Result/Wait which cause threadpool exhaustion; measures ~100-byte per async-method overhead.
AI-written summary · about
chapters (11)
- 0:00Async/await in .NET
- 1:31How async/await works
- 8:58Non-awaited tasks hide exceptions
- 13:32Async void in constructors
- 22:46Task continuation threads
- 29:07Avoid thread blocking with GetAwaiter
- 33:42Frozen collections in .NET 8
- 36:29Optimizing async with IAsyncEnumerable
- 41:27Return tasks instead of await
- 45:19ValueTask for hot path
- 50:18Summary and resources
related talks
01h 00mDIY Async Message Pump: Lessons from the trenches
59mASP .NET Basics for Experts
38mYou Keep Using That Word
42mYou Keep Using That Word
46mDIY Async Message Pump: Lessons from the trenches
49mYou Keep Using That Word: Asynchronous And Interprocess Comms (Remote)
53mYou Keep Using That Word: Asynchronous And Interprocess Comms
22mAsynchronous Computing at Scale: Overview and Learning
