csharp-background-service
CommunityRobust patterns for .NET background services
Software Engineering#queues#dotnet#error-handling#dependency-injection#background-service#cancellationtoken#hostedservice
AuthorCloudyWing
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Provides clear, practical guidelines to implement and review .NET background workers so they run reliably without crashing the host, leak scoped services, or block shutdown.
Core Features & Use Cases
- Selection Guidance: When to choose BackgroundService versus IHostedService for long-running loops or one-time initialization.
- Resilience Patterns: Proper CancellationToken propagation, loop-level exception handling, OperationCanceledException filtering, and use of PeriodicTimer to avoid overlapping ticks.
- Queue-based Workers: Channel-based producer-consumer queues with scoped service resolution via IServiceScopeFactory or IDbContextFactory for safe background processing.
- Use Case: Implement an order synchronization worker, periodic metrics collector, or HTTP-request-backed background job queue that survives errors and stops cleanly.
Quick Start
Ask the skill to review a BackgroundService implementation and report missing CancellationToken propagation, direct injection of scoped services, unhandled exceptions in loops, and registration/start-stop ordering issues.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: csharp-background-service Download link: https://github.com/CloudyWing/ai-dotfiles/archive/main.zip#csharp-background-service Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.