Correcting Common Async/Await Mistakes in .NET 8
summary
Covers concrete fixes for .NET 8 async pitfalls: non-awaited Tasks silently swallow exceptions, Task.Run fire‑and‑forget creates hidden bugs, and async methods inflate assemblies by about 80 bytes each. Demonstrates using ConfigureAwait(false) and new ConfigureAwaitOptions (including force yielding), prefers ValueTask when the hot path is sync, streams results with IAsyncEnumerable and await foreach to show items progressively, and recommends the SafeFireAndForget NuGet (≈1.7M downloads) for controlled fire‑and‑forget with exception handling.
AI-written summary · about
chapters (11)
- 0:00Introduction to async/await
- 1:03How async/await works under the hood
- 18:39Non-awaited tasks hide exceptions
- 21:25Async in constructors and fire-and-forget
- 31:23Cancellation tokens and delays
- 35:15ConfigureAwait false explained
- 41:28Why not to use Wait or Result
- 46:00Async streams with IAsyncEnumerable
- 48:30Returning Task vs await Task
- 50:38ValueTask for hot path methods
- 52:20Summary of async/await best practices
