dotnet-csharp-async-patterns

Guide async/await, ConfigureAwait, and cancellation in .NET C# code.

1|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-csharp-async-patterns-rudironsoni
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-csharp-async-patterns
Source: https://github.com/rudironsoni/dotnet-agent-harness/tree/main/.rulesync/skills/dotnet-csharp-async-patterns
Command: npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-csharp-async-patterns-rudironsoni

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps developers write correct, efficient, and robust asynchronous code in .NET, avoiding common pitfalls that lead to deadlocks, performance issues, and unhandled exceptions.

Core Features & Use Cases

  • Async/await Best Practices: Learn the "async all the way" principle, proper Task and ValueTask usage, and cancellation token propagation.
  • Agent Pitfall Avoidance: Understand and fix common mistakes AI agents make, such as blocking on async operations or using async void incorrectly.
  • Cancellation & Parallelism: Implement effective cancellation patterns and leverage Task.WhenAll and Parallel.ForEachAsync for efficient parallel execution.
  • Use Case: Ensure your ASP.NET Core application's API endpoints remain responsive under load by correctly implementing asynchronous operations and handling cancellation requests gracefully.

Quick Start

Review the core rules for writing async/await code in C#.

Frequently Asked Questions about dotnet-csharp-async-patterns

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

FAQPage Schema
How do I prevent deadlocks when using async await in C#?

To prevent deadlocks in C# async await, avoid blocking on asynchronous operations and follow the "async all the way" principle. This Skill provides guidance on proper Task execution and ConfigureAwait usage to ensure responsive code.

What is the correct way to use CancellationToken in .NET async methods?

The correct way to use CancellationToken in .NET async methods is through proper token propagation. This Skill covers implementing effective cancellation patterns to handle requests gracefully and avoid unhandled exceptions.

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

You should use ValueTask instead of Task in C# asynchronous programming when optimizing for performance to reduce allocations. This Skill explains proper Task and ValueTask usage alongside async await best practices.

How do I run parallel async operations using Task.WhenAll and Parallel.ForEachAsync?

You can run parallel async operations using Task.WhenAll and Parallel.ForEachAsync to execute multiple tasks concurrently. This Skill details these parallel execution patterns for efficient asynchronous processing in .NET.

Why should I avoid async void in C# and what are the common pitfalls?

You should avoid async void in C# because it causes unhandled exceptions and cannot be awaited. This Skill helps developers understand and fix common AI agent pitfalls like incorrect async void usage and blocking on async operations.