Asynchronous streams
summary
C# 8 adds true pull-based async streams via IAsyncEnumerable<T> and await foreach, implemented in .NET Core 3 and available for older frameworks via NuGet. Demo builds a paging client that requests pages of 5 items from a 12-item server with 3s delays and yields batches—consumer sees a 3s wait then five items, repeated; cancellation after 3s stops around item 7. MoveNextAsync uses ValueTask, enumerators support IAsyncDisposable, and buffered push-to-pull uses System.Threading.Channels.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 0:28History of async/await
- 6:21Why asynchronous streams
- 13:00Demo: Async streams
- 20:51Mental model and types
- 30:08Practical paging API
- 35:53Anti-patterns and tools
- 38:46LINQ and async streams
- 48:13Cancellation support
related talks
01h 01mThe promise of an async future awaits
58mYield at Me, 'Cause I'm Awaiting: Asynchronous Iterators in C# 8
39mPushing 'await' to the Limits: Unleashing Multi-Threading Power in .NET
01h 11mEverything You (Don’t) Want to Know About Async and Await in C#
54mC# 8 and Beyond
01h 01mI'll Get Back to You: Task, Await, and Asynchronous Methods
01h 00mCorrecting Common Async/Await Mistakes in .NET 8
43m.NET: Asyn http client - anatomy and traps
