Skip to content
Skillpedia
General coding40k · #5094

csharp-async

Provides best practices for asynchronous programming in C#. Helps write more efficient and responsive code.

What it does

This AI agent helps you write C# code more efficiently and safely by following best practices for asynchronous programming. It checks your code to ensure it's fast and avoids common errors.

When to use it

  • ✓When writing C# code that needs to do multiple things at once without freezing.
  • ✓When you want your program to respond more quickly.
  • ✓To avoid common mistakes in C# code that handles long-running operations.

Example of what to ask your AI

“Review this C# code and tell me if I'm using asynchronous programming correctly: [your C# code here]”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/github/awesome-copilot/blob/main/skills/csharp-async/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/csharp-async/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The agent compares your code against a set of rules and recommendations for C# asynchronous programming. It identifies where you can improve naming, error handling, performance, and avoid common pitfalls.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add github/awesome-copilot --skill csharp-async

Or download just the file:

curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/csharp-async/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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() for GetData())

Return Types

  • Return Task<T> when the method returns a value
  • Return Task when the method doesn't return a value
  • Consider ValueTask<T> for high-performance scenarios to reduce allocations
  • Avoid returning void for async methods except for event handlers

Exception Handling

  • Use try/catch blocks around await expressions
  • Avoid swallowing exceptions in async methods
  • Use ConfigureAwait(false) when appropriate to prevent deadlocks in library code
  • Propagate exceptions with Task.FromException() instead of throwing in async Task returning methods

Performance

  • Use Task.WhenAll() for parallel execution of multiple tasks
  • Use Task.WhenAny() for implementing timeouts or taking the first completed task
  • Avoid unnecessary async/await when simply passing through task results
  • Consider cancellation tokens for long-running operations

Common Pitfalls

  • Never use .Wait(), .Result, or .GetAwaiter().GetResult() in async code
  • Avoid mixing blocking and async code
  • Don't create async void methods (except for event handlers)
  • Always await Task-returning methods

Implementation Patterns

  • Implement the async command pattern for long-running operations
  • Use async streams (IAsyncEnumerable<T>) for processing sequences asynchronously
  • Consider the task-based asynchronous pattern (TAP) for public APIs

When reviewing my C# code, identify these issues and suggest improvements that follow these best practices.

FAQ

What is asynchronous programming?

It's a way of writing code that allows your program to do other things while waiting for a time-consuming task (like fetching data from the internet) to finish, instead of just waiting idly.

Why should I use best practices?

Following best practices makes your code faster, easier to understand, less prone to bugs, and simpler to maintain by you and other programmers.

What are 'deadlocks'?

Deadlocks occur when two or more parts of your code are waiting for each other indefinitely, causing the program to freeze.

Details

Original description by the author

Get best practices for C# async programming

repo: github/awesome-copilot

Popularity

GitHub stars
40k
Ranking position
#5094
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills