๐จ Awesome .Net Async
Curated list of awesome articles and resources to learning and practicing about async, threading, and channels in .Net platform. this repository will be updated continuously, keep yourself up to date
๐
Contributions are always welcome! Please take a look at the contribution guidelines pages first.
Thanks to all contributors, you're awesome and wouldn't be possible without you! The goal is to build a categorized community-driven collection of very well-known resources.
Contents
- Async And Await
- Cancellation
- IO-Bound
- Cpu-Bound
- TaskCompletionSource
- Task
- ValueTask
- Configure Await
- Exception Handling
- SynchronizationContext
- Awaiter
- Continuations
- Thread Pool
- Thread
- Async Tips
- Concurrency Vs Parallelism
- Async Local
- Thread Safey
- Asynchronous Messaging
- Async Collections
- Async Stream And IEnumerableAsync
- Lazy Initialization
- Iterators
- Channels
- Libraries
- Code Analyzers
- Other Resources
Async And Await
๐ Articles
- Async Overview
- Asynchronous programming patterns
- Task-based asynchronous pattern - TAP
- Event-based Asynchronous Pattern - EAP
- Asynchronous Programming Model - APM
- Task asynchronous programming model
- Async return types (C#)
- When to Use Async and Await and How it Works
- Asynchrony in C# 5 Part Six: Whither async?
- Exploring the async/await State Machine โ Series Overview
- Exploring the async/await State Machine โ The Awaitable Pattern
- Exploring the async/await State Machine โ Main Workflow and State Transitions
- Exploring the async/await State Machine โ Conceptual Implementation
- Dissecting the async methods in C#
- Extending the async methods in C#
- Understanding async/await State Machine in .NET
- Fixing the Sync over Async antipattern
- Parallel Programming BY examples
- Async/Await FAQ
- Are deadlocks still possible with await?
- Explaining Async and Await in ASP.NET
- A Practical Example Of Asynchronous Programming in C# and ASP.NET
- The Ultimate Guide to Async and Await in C# and ASP.NET
Cancellation
๐ Articles
- Task cancellation in C# and things you should know about it
- Cancel asynchronous operation in csharp
- Aborting Thread Vs Cancelling Task
- Task cancellation
- Cancellation in Managed Threads
- Destroying threads
- How to: Cancel a Task and Its Children
- Using CancellationTokens in ASP.NET Core MVC controllers
- Canceling HTTP Requests in ASP.NET Core with CancellationToken
๐ Samples
IO-Bound
๐ Articles
- Deeper Dive into Tasks for an I/O-Bound Operation
- I/O-bound tasks
- Why you should not create asynchronous wrappers with Task.Run()
- Asynchronous file access (C#)
- C# : TASK PARALLEL LIBRARY (TPL) WITH ASYNC AWAIT AND TASKCOMPLETIONSOURCE FOR ASYNC I/O OPERATIONS
- There Is No Thread
- Wrapping Other Asynchronous Patterns in Awaitable Tasks
- Task.Factory.StartNew vs Task.Factory.FromAsync
- Task.Run vs Task.Factory.StartNew
Cpu-Bound
๐ Articles
- Compute-bound tasks
- Task.Run Etiquette and Proper Usage
- Should I expose asynchronous wrappers for synchronous methods?
- Task.Run Vs TaskCompletionSource Vs Task.Factory.FromAsync
- Task.Run vs Task.Factory.StartNew
TaskCompletionSource
๐ Articles
- Should I expose asynchronous wrappers for synchronous methods?
- Using TaskCompletionSource to change the semantics of async calls
- TaskCompletionSource in real life (part 1 of 2)
- TaskCompletionSource in real life (part 2 of 2)
- C# : TASK PARALLEL LIBRARY (TPL) WITH ASYNC AWAIT AND TASKCOMPLETIONSOURCE FOR ASYNC I/O OPERATIONS
- Task.Run Vs TaskCompletionSource Vs Task.Factory.FromAsync
- The Nature of TaskCompletionSource - Stephen Toub
- When should TaskCompletionSourceT be used?
- Instance of Task class (Task.Factory.StartNew or TaskCompletionSource)
- Wrapping Other Asynchronous Patterns in Awaitable Tasks
- The danger of TaskCompletionSource class
- Mechanisms for Creating Tasks
Task
Articles
- Mechanisms for Creating Tasks - Stephen Toub
- Task Class
- New Task APIs in .NET 4.6 - Stephen Toub
- Tasks, Monads, and LINQ - Stephen Toub
- Serial vs Parallel task execution
ValueTask
๐ Articles
- ValueTask Restrictions - Stephen Cleary
- How to use ValueTask in C#
- Task, Async Await, ValueTask, IValueTaskSource and how to keep your sanity in modern .NET world
- .NET 5 and pooling for ValueTasks - Scooletz
๐น Videos
- Understanding how to use Task and ValueTask
- When to use ValueTask instead of Task and save precious memory in C#
Configure Await
๐ Articles
Exception Handling
๐ Articles
- Exception Handling In Asynchronous Code
- Exception Handling in C# Asynchronous Programming
- Exception handling (Task Parallel Library)
- Asynchrony in C# 5, Part Seven: Exceptions
SynchronizationContext
๐ Articles
Awaiter
๐ Articles
- A Tour of Task, Part 6: Results
- Task.Wait() Vs Task.GetAwaiter().GetResult()
- Avoid GetAwaiter().GetResult() at all cost
- Understanding C# async / await (2) The Awaitable-Awaiter Pattern
Continuations
๐ Articles
Thread Pool
Thread
๐ Articles
Async Tips
๐ Articles
- Async Guidance
- Async and Await: Here be dragons
- Top 7 Common Async Mistakes
- Async/Await - Best Practices in Asynchronous Programming
- Common C# async and await misconceptions
- Cancel Asynchronous Operation In Csharp - John Thiriet
- C# Async Tips and Tricks - Chris Pratt
- Eliding Async and Await - Stephen Cleary
- Async code smells and how to track them down with analyzers - Part I
- Async code smells and how to track them down with analyzers - Part II
- Two Ways to Do Async/Await in ASP.NET Wrong (and How to Fix Them)
Videos
๐ Samples
- https://github.com/davidfowl/AspNetCoreDiagnosticScenarios
This repository has examples of broken patterns in ASP.NET Core applications
Concurrency Vs Parallelism
๐ Articles
- Concurrency Vs Parallelism
- Concurrency, part 1: Parallelism, Asynchrony, and Multi-threading Explained
Async Local
๐ Articles
- AsyncLocalT in .NET 4.6
- Implicit Async Context ("AsyncLocal")
- Multithreaded shared variables and AsyncLocal
Thread Safey
๐ Articles
Asynchronous Messaging
๐ Articles
- Asynchronous Messaging, Part 1: Basic Distributed Architecture
- Asynchronous Messaging, Part 2: Durable Queues
- Asynchronous Messaging, Part 3: Backend Service
Async Collections
BlockingCollection
๐ Articles
- BlockingCollection Overview
- Event-driven .NET: Concurrent Producer/Consumer using BlockingCollection
- An introduction to BlockingCollection
Async Stream And IEnumerableAsync
๐ Articles
- Use streaming in ASP.NET Core SignalR
- Async Streams
- Iterating with Async Enumerables in C# 8
- Async Streams with IAsyncEnumerable in .NET Core 3
- IAsyncEnumerable Is Your Friend, Even In .NET Core 2.x
- Asynchronous streams in C# 8.0
- gRPC and C# 8 Async stream
- gRPC and C# 8 Async stream cancellation
Lazy Initialization
๐ Articles
Iterators
๐ Articles
Channels
๐น Videos
๐ Articles
- An Introduction to System.Threading.Channels - Stephen Toub
- Using Channels In C# .NET Core โ Part 1 โ Getting Started
- Using Channels In C# .NET Core โ Part 2 โ Advanced Channels
- Using Channels In C# .NET Core โ Part 3 โ Understanding Back Pressure
- AN INTRODUCTION TO SYSTEM.THREADING.CHANNELS
- Producer/consumer pipelines with System.Threading.Channels
- C# Channels - Publish / Subscribe Workflows
- C# Channels - Timeout and Cancellation
- C# Channels - Async Data Pipelines
- How to implement Producer/Consumer with System.Threading.Channels
- How to implement Producer/Consumer with System.Threading.Channels
- What's the Difference between Channel and ConcurrentQueue in C#?
๐ Samples
Libraries
-
A helper library for the Task-Based Asynchronous Pattern (TAP).
-
Microsoft.VisualStudio.Threading
Async synchronization primitives, async collections, TPL and dataflow extensions. The JoinableTaskFactory allows synchronously blocking the UI thread for async work.
-
Introduces
IAsyncEnumerable
,IAsyncEnumerator
,ForEachAsync()
, andParallelForEachAsync()
and other useful stuff to use with async-await -
Easy-to-use library for common async IO file system operations.
-
A C# lock replacement for async/await, supporting recursion/re-entrance and asynchronous waits.
Code Analyzers
-
Microsoft.VisualStudio.Threading.Analyzers
Static code analyzer to detect common mistakes or potential issues regarding threading and async coding.
-
AsyncFixer helps developers in finding and correcting common async/await misuses (i.e., anti-patterns).
-
ConfigureAwaitChecker.Analyzer
Checks for
ConfigureAwait(false)
usage. -
Lindhart.Analyser.MissingAwaitWarning
Compiler analyser to generate Warnings whenever a Task is not awaited nor assigned to a variable.