csharp-async
Installation
Summary
Best practices guide for C# asynchronous programming patterns and pitfalls.
- Covers naming conventions (Async suffix), return types (Task, ValueTask, avoid void), and exception handling strategies including ConfigureAwait and Task.FromException
- Highlights performance optimization techniques: Task.WhenAll for parallel execution, Task.WhenAny for timeouts, and cancellation token usage
- Documents critical pitfalls to avoid: blocking calls like .Wait() and .Result, async void methods outside event handlers, and mixing blocking with async code
- Recommends implementation patterns including async command pattern, async streams (IAsyncEnumerable), and task-based asynchronous pattern (TAP) for public APIs
SKILL.md
C# Async Programming Best Practices
Your goal is to help me follow best practices for asynchronous programming in C#.
Naming Conventions
- Use the 'Async' suffix for all async methods
- Match method names with their synchronous counterparts when applicable (e.g.,
GetDataAsync()forGetData())
Return Types
- Return
Task<T>when the method returns a value - Return
Taskwhen the method doesn't return a value - Consider
ValueTask<T>for high-performance scenarios to reduce allocations - Avoid returning
voidfor async methods except for event handlers