csharp-async

द्वारा github

C# एसिंक्रोनस प्रोग्रामिंग पैटर्न और समस्याओं के लिए सर्वोत्तम अभ्यास मार्गदर्शिका। नामकरण परंपराओं (Async प्रत्यय), रिटर्न प्रकार (Task, ValueTask, void से बचें), और ConfigureAwait और Task.FromException सहित अपवाद हैंडलिंग रणनीतियों को शामिल करता है। प्रदर्शन अनुकूलन तकनीकों पर प्रकाश डालता है: समानांतर निष्पादन के लिए Task.WhenAll, टाइमआउट के लिए Task.WhenAny, और कैंसलेशन टोकन का उपयोग। महत्वपूर्ण समस्याओं का दस्तावेजीकरण करता है जिनसे बचना चाहिए

npx skills add https://github.com/github/awesome-copilot --skill csharp-async

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) 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.

github की और Skills

console-rendering
github
Go में struct टैग-आधारित कंसोल रेंडरिंग सिस्टम का उपयोग करने के निर्देश
official
acquire-codebase-knowledge
github
इस कौशल का उपयोग तब करें जब उपयोगकर्ता स्पष्ट रूप से किसी मौजूदा कोडबेस का मानचित्रण, दस्तावेज़ीकरण या उसमें शामिल होने का अनुरोध करे। "इस कोडबेस का मानचित्रण करें", "दस्तावेज़ीकरण करें..." जैसे संकेतों के लिए ट्रिगर करें।
official
acreadiness-assess
github
Run the AgentRC readiness assessment on the current repository and produce a static HTML dashboard at reports/index.html. Wraps `npx github:microsoft/agentrc…
official
acreadiness-generate-instructions
github
एजेंटआरसी निर्देश कमांड के माध्यम से अनुकूलित AI एजेंट निर्देश फ़ाइलें उत्पन्न करता है। .github/copilot-instructions.md (डिफ़ॉल्ट, VS में Copilot के लिए अनुशंसित) उत्पन्न करता है…
official
acreadiness-policy
github
उपयोगकर्ता को AgentRC नीति चुनने, लिखने या लागू करने में सहायता करें। नीतियाँ अप्रासंगिक जाँचों को अक्षम करके, प्रभाव/स्तर को ओवरराइड करके, सेट करके तत्परता स्कोरिंग को अनुकूलित करती हैं…
official
add-educational-comments
github
कोड फ़ाइलों में शैक्षिक टिप्पणियाँ जोड़कर उन्हें प्रभावी शिक्षण संसाधनों में बदलें। व्याख्या की गहराई और लहज़े को तीन कॉन्फ़िगरेबल ज्ञान स्तरों के अनुसार अनुकूलित करता है: शुरुआती, मध्यवर्ती और उन्नत। यदि कोई फ़ाइल प्रदान नहीं की गई है तो स्वचालित रूप से एक फ़ाइल का अनुरोध करता है, त्वरित चयन के लिए क्रमांकित सूची मिलान के साथ। केवल शैक्षिक टिप्पणियों का उपयोग करके फ़ाइलों को 125% तक विस्तारित कर
official
adobe-illustrator-scripting
github
एक्सटेंडस्क्रिप्ट (जावास्क्रिप्ट/JSX) का उपयोग करके Adobe Illustrator ऑटोमेशन स्क्रिप्ट लिखें, डीबग करें और ऑप्टिमाइज़ करें। उन स्क्रिप्ट को बनाने या संशोधित करने के लिए उपयोग करें जो…
official
agent-governance
github
एजेंट टूल एक्सेस और व्यवहार को नियंत्रित करने के लिए घोषणात्मक नीतियां, इरादा वर्गीकरण और ऑडिट ट्रेल्स। कंपोजेबल गवर्नेंस नीतियां अनुमत/अवरुद्ध टूल, सामग्री फ़िल्टर, दर सीमाएं और अनुमोदन आवश्यकताओं को परिभाषित करती हैं — कॉन्फ़िगरेशन के रूप में संग्रहीत, कोड नहीं। सिमैंटिक इरादा वर्गीकरण टूल निष्पादन से पहले पैटर्न-आधारित संकेतों का उपयोग करके खतरनाक प्रॉम्प्ट
official