csharp-concurrency-patterns
Navigate .NET concurrency from async/await through Channels to Akka.NET based on your specific problem.
- Start with
async/awaitfor I/O-bound work; escalate only when you hit a concrete limitation that simpler tools can't address cleanly - Use
Parallel.ForEachAsyncfor CPU-bound parallelism,Channel<T>for producer/consumer decoupling with backpressure, and Reactive Extensions for UI event composition - Akka.NET Actors handle stateful entity management, state machines with
Become(), and distributed scenarios; Akka.NET Streams provide server-side batching and throttling - Avoid locks, manual thread creation, and blocking on async code; prefer immutability, message passing, and
System.Collections.Concurrentwhen shared state is unavoidable
.NET Concurrency: Choosing the Right Tool
When to Use This Skill
Use this skill when:
- Deciding how to handle concurrent operations in .NET
- Evaluating whether to use async/await, Channels, Akka.NET, or other abstractions
- Tempted to use locks, semaphores, or other synchronization primitives
- Need to process streams of data with backpressure, batching, or debouncing
- Managing state across multiple concurrent entities
Reference Files
- advanced-concurrency.md: Akka.NET Streams, Reactive Extensions, Akka.NET Actors (entity-per-actor, state machines, cluster sharding), and async local function patterns
The Philosophy
Start simple, escalate only when needed.
More from aaronontheweb/dotnet-skills
modern-csharp-coding-standards
Write modern, high-performance C# code using records, pattern matching, value objects, async/await, Span<T>/Memory<T>, and best-practice API design patterns. Emphasizes functional-style programming with C# 12+ features.
1.3Kefcore-patterns
Entity Framework Core best practices including NoTracking by default, query splitting for navigation collections, migration management, dedicated migration services, and common pitfalls to avoid.
977dotnet-project-structure
Modern .NET project structure including .slnx solution format, Directory.Build.props, central package management, SourceLink, version management with RELEASE_NOTES.md, and SDK pinning with global.json.
272api-design
Design stable, compatible public APIs using extend-only design principles. Manage API compatibility, wire compatibility, and versioning for NuGet packages and distributed systems.
263type-design-performance
Design .NET types for performance. Seal classes, use readonly structs, prefer static pure functions, avoid premature enumeration, and choose the right collection types.
262dependency-injection-patterns
Organize DI registrations using IServiceCollection extension methods. Group related services into composable Add* methods for clean Program.cs and reusable configuration in tests.
257