Correcting Common Async/Await Mistakes in .NET 10
summary
Shows that the C# compiler generates an IAsyncStateMachine (usually a struct for release builds), wraps moveNext in a giant try/catch so un-awaited tasks hide exceptions, and the async keyword adds about 80 bytes to the DLL. Demonstrates concrete fixes: always await tasks or use a guarded SafeFireAndForget helper/nuget, prefer ConfigureAwait(false) or ConfigureAwaitOptions (force yielding / suppress throwing), stream results with ToAsyncEnumerable/Task.WhenEach in .NET 10, use ValueTask and avoid .Result/.Wait to stop thread blocking and lost exceptions.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:25How async await works
- 5:49Compiler generated code
- 10:49State machine breakdown
- 19:16Common async mistakes
- 23:49Refactoring a WPF app
- 31:18Advanced async techniques
- 37:05Configuring await behavior
- 43:23Performance improvements
- 50:58Hot path optimizations
- 57:09Conclusion and resources
related talks
01h 00mCorrecting Common Async/Await Mistakes in .NET
01h 01mCorrecting Common Async/Await Mistakes in .NET 9
49mCorrecting Common Mistakes in Asynchronous .NET Code
01h 00mCorrecting Common Async/Await Mistakes in .NET 8
56mCorrecting Common Async/Await Mistakes in .NET 8
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
