Async programming in .NET: Best practices
summary
Claims that async/await semantics hide dangerous defaults and many Task options cause surprising behavior, shows a real production deadlock in a Rider-style pipeline caused by TaskCreationOptions/TaskScheduler and a TaskCompletionSource running continuations synchronously, and proves fixes: replace a blocking queue and locks with System.Threading.Channels, avoid implicit SynchronizationContext by using ConfigureAwait(false) and explicit cancellation via async locals, and simplify lifecycle and cancellation with JetBrains.Lifetimes — the rewritten channel-based pipeline is shorter, deterministic and eliminates the intermittent races.
AI-written summary · about
chapters (11)
- 0:00Introduction to async
- 1:24Tooling issues
- 4:15Async programming evolution
- 10:56Task parameters complexity
- 27:57Async/await solutions
- 36:20Context and threads
- 40:37Real-world example
- 47:05Parallel async code
- 47:48Locks to channels
- 50:35Best practices summary
- 52:24Q&A
related talks
01h 00mAvoiding common pitfalls with async/await
58mBack to Basics: Efficient Async and Await
55mAsync internals in .NET
59mAsynchronous Programming From The Ground Up
57mBack to Basics: Efficient Async and Await
01h 15mBest Practices for Using async and await
01h 00mCorrecting Common Async/Await Mistakes in .NET 8
01h 03mDesigning and rewriting asynchronous tasks from scratch
