csharp-async

Apply C# async best practices to reduce race conditions and deadlocks.

1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/afonsoft/VideoChat --skill csharp-async-afonsoft
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-async
Source: https://github.com/afonsoft/VideoChat/tree/main/.agents/skills/csharp-async
Command: npx skills add https://github.com/afonsoft/VideoChat --skill csharp-async-afonsoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide helps developers adopt best practices for asynchronous programming in C#, reducing common bugs and improving reliability and performance across IO-bound and CPU-bound work.

Core Features & Use Cases

  • Naming conventions: suffix async for asynchronous methods and align names with their synchronous counterparts to improve readability.
  • Return types and error handling: use Task/Task<T>, consider ValueTask for allocations-sensitive paths, and propagate exceptions without blocking.
  • Performance and pitfalls: use Task.WhenAll for parallelism, avoid .Wait() and .Result, and apply ConfigureAwait(false) in library code to prevent deadlocks.
  • Use cases: applies to libraries, services, data access, APIs, and background processing that rely on asynchronous operations.

Quick Start

Refactor the given method to use asynchronous programming patterns safely and efficiently.

Frequently Asked Questions about csharp-async

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid deadlocks in C# async code?

To avoid deadlocks in C# async code, use ConfigureAwait(false) in library code and never call .Wait() or .Result. These practices prevent thread-pool starvation and ensure safe, reliable asynchronous operations.

When should I use ValueTask instead of Task in C#?

Use ValueTask instead of Task in C# for allocation-sensitive paths to reduce memory overhead. ValueTask improves performance in hot paths, while Task remains suitable for standard asynchronous operations and general exception handling.

What are the best practices for async naming conventions in C#?

Best practices for async naming conventions in C# require adding the Async suffix to asynchronous methods. Align method names with their synchronous counterparts to improve readability and maintain consistency across libraries and services.

How do I run parallel IO-bound operations in C# async?

To run parallel IO-bound operations in C# async, use Task.WhenAll. This pattern executes multiple tasks concurrently, improving performance, while proper exception handling ensures errors propagate without blocking the application.

Why does my C# async method cause thread-pool pressure?

C# async methods cause thread-pool pressure when blocking calls like .Result or .Wait() are used. Replacing them with await, using ConfigureAwait(false), and applying Task.WhenAll for parallelism reduce thread-pool exhaustion.

Can I use async patterns for CPU-bound work in C#?

Yes, you can use async patterns for CPU-bound work in C# by offloading operations to background tasks. This prevents blocking the main thread, while proper return types and exception handling maintain reliable event-driven processing.