I'll Get Back to You: Task, Await, and Asynchronous Methods
summary
C# demos show a WPF app with three buttons and a listbox, using Task.Delay(3000) to simulate async work and exposing the real pitfalls: deadlocks from accessing Task.Result on the UI thread, the pain of ContinueWith’s ~40 overloads and using TaskScheduler.FromCurrentSynchronizationContext to marshal back, how await preserves context (and how ConfigureAwait(false) breaks UI marshaling), handling AggregateException via AggregateException.Flatten, and cancellation with CancellationTokenSource and token.ThrowIfCancellationRequested.
AI-written summary · about
chapters (24)
- 0:00Introduction
- 1:00Asynchronous Patterns
- 6:30Task Delay
- 10:09Event Handler Setup
- 10:54Task of List of Person
- 11:35Task for Results
- 20:38From Current Synchronization Context
- 22:16Using Lambda Expressions
- 27:51Await
- 31:39ConfigureWaitFalse
- 33:15UI Issues
- 34:38Await Button
- 36:08Task Button
- 37:38Exception Handling
- 39:30Aggregate Exception
- 40:00If Statement
- 40:26Cancel Statement
- 41:48Status Property
- 43:26flattenat
- 45:24catch exception
- 46:46cancellation
- 49:34testing
- 54:38cancel token
- 56:39Await method
related talks
59mAsynchronous Programming From The Ground Up
58mBack to Basics: Efficient Async and Await
01h 11mEverything You (Don’t) Want to Know About Async and Await in C#
01h 00mAvoiding common pitfalls with async/await
55mAsync internals in .NET
01h 00mCorrecting Common Async/Await Mistakes in .NET
51mAsync Internals in .NET
01h 01mCorrecting Common Async/Await Mistakes in .NET 9
