Back to Basics: Efficient Async and Await
summary
Demonstrates why await easily deadlocks when the state machine runs on the caller thread and that Task continuations often swallow exceptions, showing a 2s Task.Delay example that returns "hello world" only if awaited correctly. Recommends returning Task instead of void, avoiding .Result/.Wait/Task.Wait, reducing unnecessary state machines by returning inner tasks, and using CancellationTokenSource for 400ms debounce smart cancellations. Concrete rules: async void crashes app, async all the way, and use ConfigureAwait(false) in ASP.NET to avoid context capture.
AI-written summary · about
chapters (16)
- 0:00Start
- 2:16Why bother?
- 3:17Leverage all Resources
- 4:47Async + Parallel
- 6:35Blocking - Non Blocking Code
- 9:00Task Parallel Library
- 9:56What's a Task?
- 17:48private async Task RunAsync()
- 20:29await vs Task.ContinueWith?
- 21:28async & await - The Bad
- 26:54State Machine?
- 28:11Post Compilation
- 29:44Inside the State Machine
- 31:38Is it really that bad?
- 35:39How do we fix it?
- 36:18Deadlocks...
related talks
58mBack to Basics: Efficient Async and Await
59mAsynchronous Programming From The Ground Up
01h 15mBest Practices for Using async and await
01h 11mEverything You (Don’t) Want to Know About Async and Await in C#
01h 00mCorrecting Common Async/Await Mistakes in .NET
49mCorrecting Common Mistakes in Asynchronous .NET Code
55mAsync internals in .NET
01h 05mCorrecting Common Async/Await Mistakes in .NET 10
