Skip to content
Skillpedia
General coding40k · #7151

csharp-async

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.

Skill link

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

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

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.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

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]”

5 new skills a week. 1 minute to read.

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.

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
#7151
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills