
Csharp Concurrency Patterns
Apply proven Akka.NET, Rx, and async patterns when your .NET service needs streams, actors, or UI event composition without reinventing concurrency.
Overview
csharp-concurrency-patterns is an agent skill for the Build phase that teaches advanced C# concurrency with Akka.NET Streams, Reactive Extensions, actors, and async-local patterns.
Install
npx skills add https://github.com/aaronontheweb/dotnet-skills --skill csharp-concurrency-patternsWhat is this skill?
- Akka.NET Streams recipes for GroupedWithin batching, Throttle shaping, and SelectAsync parallel processing
- Reactive Extensions guidance for UI and event-composition scenarios
- Akka.NET actor patterns for stateful concurrent workloads
- Guidance to prefer async local functions over ad-hoc threading
- Runnable graph and DSL examples you can paste into production services
- Four documented pattern areas: Akka.NET Streams, Reactive Extensions, Akka.NET Actors, and async local functions
- Example stream settings include GroupedWithin(100, 1s), Throttle(10 per second), and SelectAsync parallelism of 4
Adoption & trust: 1.1k installs on skills.sh; 989 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need backpressure, batching, throttling, or actor-style state without drowning in brittle locks, Task.Run soup, or one-off stream hacks.
Who is it for?
Indie builders extending a .NET API, worker, or reactive client where throughput, ordering, or UI event streams need explicit stream or actor semantics.
Skip if: Teams still learning async/await basics or greenfield apps that only need simple CRUD with no stream processing—start with foundational C# async material first.
When should I use this skill?
Use when implementing advanced concurrency in .NET with streams, actors, Rx, or structured async locals beyond basic Task usage.
What do I get? / Deliverables
You implement stream graphs, Rx compositions, or actor models with copy-ready .NET examples aligned to each advanced concurrency scenario.
- Stream or actor pipeline code following documented Akka.NET and Rx patterns
- Concurrency structure using async local functions where appropriate
Recommended Skills
Journey fit
Concurrency pattern catalogs belong on the Build shelf because they guide implementation of server-side and reactive .NET code, not idea research or post-ship ops. Content targets backend pipelines (streams, actors, throttling) and Rx for event composition—canonical home is backend rather than generic docs or frontend-only UI work.
How it compares
Use as a pattern cookbook for .NET concurrency primitives, not as a one-shot code generator or an MCP integration server.
Common Questions / FAQ
Who is csharp-concurrency-patterns for?
Solo and small-team .NET developers building services or reactive clients who already ship C# and want agent-guided Akka.NET, Rx, and async structure instead of trial-and-error threading.
When should I use csharp-concurrency-patterns?
During Build when you are wiring ingestion pipelines, rate limits, parallel transforms, UI event streams, or actor-hosted state in a .NET codebase and need vetted pattern choices.
Is csharp-concurrency-patterns safe to install?
Treat it as documentation-style guidance; review the Security Audits panel on this Prism page and your org policy before letting an agent apply snippets into production payment or PII paths.
SKILL.md
READMESKILL.md - Csharp Concurrency Patterns
# Advanced Concurrency Patterns Akka.NET Streams, Reactive Extensions, Akka.NET Actors, and async local function patterns for advanced concurrency scenarios. ## Contents - [Akka.NET Streams (Complex Stream Processing)](#akkanet-streams-complex-stream-processing) - [Reactive Extensions (UI and Event Composition)](#reactive-extensions-ui-and-event-composition) - [Akka.NET Actors (Stateful Concurrency)](#akkanet-actors-stateful-concurrency) - [Prefer Async Local Functions](#prefer-async-local-functions) ## Akka.NET Streams (Complex Stream Processing) **Use for:** Backpressure, batching, debouncing, throttling, merging streams, complex transformations. ```csharp using Akka.Streams; using Akka.Streams.Dsl; // Batching with timeout public Source<IReadOnlyList<Event>, NotUsed> BatchEvents( Source<Event, NotUsed> events) { return events .GroupedWithin(100, TimeSpan.FromSeconds(1)) // Batch up to 100 or 1 second .Select(batch => batch.ToList() as IReadOnlyList<Event>); } // Throttling public Source<Request, NotUsed> ThrottleRequests( Source<Request, NotUsed> requests) { return requests .Throttle(10, TimeSpan.FromSeconds(1), 5, ThrottleMode.Shaping); } // Parallel processing with ordered results public Source<ProcessedItem, NotUsed> ProcessWithParallelism( Source<Item, NotUsed> items) { return items .SelectAsync(4, async item => await ProcessAsync(item)); // 4 parallel } // Complex pipeline public IRunnableGraph<Task<Done>> CreatePipeline( Source<RawEvent, NotUsed> events, Sink<ProcessedEvent, Task<Done>> sink) { return events .Where(e => e.IsValid) .GroupedWithin(50, TimeSpan.FromMilliseconds(500)) .SelectAsync(4, batch => ProcessBatchAsync(batch)) .SelectMany(results => results) .ToMaterialized(sink, Keep.Right); } ``` **Akka.NET Streams excel at:** - Batching with size AND time limits - Throttling and rate limiting - Backpressure that propagates through the entire pipeline - Merging/splitting streams - Parallel processing with ordering guarantees - Error handling with supervision ## Reactive Extensions (UI and Event Composition) **Use for:** UI event handling, composing event streams, time-based operations in client applications. Rx shines in UI scenarios where you need to react to user events with debouncing, throttling, or combining multiple event sources. ```csharp using System.Reactive.Linq; // Search-as-you-type with debouncing public class SearchViewModel { public SearchViewModel(ISearchService searchService) { SearchResults = SearchText .Throttle(TimeSpan.FromMilliseconds(300)) // Wait for typing to pause .DistinctUntilChanged() // Ignore if same text .Where(text => text.Length >= 3) // Minimum length .SelectMany(text => searchService.SearchAsync(text).ToObservable()) .ObserveOn(RxApp.MainThreadScheduler); // Back to UI thread } public IObservable<string> SearchText { get; } public IObservable<IList<SearchResult>> SearchResults { get; } } // Combining multiple UI events public IObservable<bool> CanSubmit => Observable.CombineLatest( UsernameValid, PasswordValid, EmailValid, (user, pass, email) => user && pass && email); // Double-click detection public IObservable<Point> DoubleClicks => MouseClicks .Buffer(TimeSpan.FromMilliseconds(300)) .Where(clicks => clicks.Count >= 2) .Select(clicks => clicks.Last()); // Auto-save with debouncing public IDisposable AutoSave => DocumentChanges .Throttle(TimeSpan.FromSeconds(2)) .Subscribe(async doc => await SaveAsync(doc)); ``` **Rx is ideal for:** - UI event composition (WPF, WinForms, MAUI, Blazor) - Search-as-you-type with debouncing - Combining multiple event sources - Time-windowed operations in UI - Drag-and-drop gesture detection - Real-time data visual