本文へスキップ
Skillpedia
一般的なプログラミング40k · #7151

csharp-async

できること

このAIエージェントは、非同期プログラミングのベストプラクティスに従って、C#のコードをより効率的かつ安全に書く手助けをします。コードを確認し、高速で、よくある間違いを避けられるようにします。

使う場面

  • ✓処理を止めずに複数の作業を同時に行う必要があるC#コードを書くとき。
  • ✓プログラムの応答をより速くしたいとき。
  • ✓時間のかかる処理を扱うC#コードでよくある間違いを避けたいとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/github/awesome-copilot/blob/main/skills/csharp-async/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このC#コードを確認して、非同期プログラミングを正しく使えているか教えてください:[ここにC#コードを入力]”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、あなたのコードをC#の非同期プログラミングのためのルールや推奨事項と照らし合わせます。命名、エラー処理、パフォーマンスを改善できる箇所を特定し、よくある落とし穴を避ける方法を示します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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.

よくある質問

非同期プログラミングとは何ですか?

インターネットからデータを取得するような時間のかかる処理が終わるのを、ただ待つのではなく、プログラムが他の作業を進められるようにする書き方のことです。

なぜベストプラクティスに従うべきなのですか?

ベストプラクティスに従うと、コードが速くなり、理解しやすくなり、バグが起きにくくなり、自分や他のプログラマーが保守しやすくなります。

「デッドロック」とは何ですか?

コードの二つ以上の部分が互いの処理を無期限に待ち続けてしまい、プログラムが固まってしまう状態のことです。

詳細

作者による元の説明

Get best practices for C# async programming

repo: github/awesome-copilot

人気

GitHubのスター
40k
ランキング
#7151
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル