Agent skill

dotnet-async-lite

비동기 프로그래밍 핵심 패턴

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/dotnet-async-lite

SKILL.md

비동기 프로그래밍 핵심

1. Task vs ValueTask

csharp
// 일반 비동기: Task 사용
public async Task<Data> LoadAsync() { }

// 캐시 히트 빈번: ValueTask 사용
public ValueTask<Data> GetAsync(string key)
{
    if (_cache.TryGetValue(key, out var cached))
        return new ValueTask<Data>(cached);

    return new ValueTask<Data>(LoadFromDbAsync(key));
}

2. CancellationToken

csharp
public async Task<Data> LoadAsync(CancellationToken ct = default)
{
    ct.ThrowIfCancellationRequested();
    return await _httpClient.GetFromJsonAsync<Data>(url, ct);
}

// 타임아웃
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
await LongOperationAsync(cts.Token);

3. 안티패턴

csharp
// ❌ async void 금지
public async void BadMethod() { }

// ❌ .Result, .Wait() 금지 (데드락)
var result = GetDataAsync().Result;

// ✅ await 사용
var result = await GetDataAsync();

상세 내용: /dotnet-async skill 참조

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results