dotnet-worker-services

Develop long-running .NET background services with Generic Host patterns.

466|35|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/managedcode/dotnet-skills --skill dotnet-worker-services
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-worker-services
Source: https://github.com/managedcode/dotnet-skills/tree/main/skills/dotnet-worker-services
Command: npx skills add https://github.com/managedcode/dotnet-skills --skill dotnet-worker-services

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides the patterns and best practices for building reliable, long-running background services and hosted services in .NET, ensuring proper lifecycle management, graceful shutdown, and efficient resource utilization.

Core Features & Use Cases

  • BackgroundService Implementation: Learn to implement BackgroundService for scheduled or continuous tasks.
  • Graceful Shutdown: Ensure your services shut down cleanly without data loss.
  • Dependency Management: Handle scoped dependencies correctly within hosted services.
  • Observability: Integrate health checks for monitoring and reliability.
  • Use Case: Develop a worker service that periodically polls a message queue, processes messages, and updates a database, all while ensuring it can be stopped and restarted safely.

Quick Start

Implement a basic .NET worker service using the BackgroundService pattern.

Frequently Asked Questions about dotnet-worker-services

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a .NET BackgroundService for continuous background data processing?

A .NET BackgroundService is implemented by inheriting from the BackgroundService base class and overriding ExecuteAsync. This Skill provides patterns for developing continuous background data processing tasks using the Generic Host in .NET.

What is the best way to handle graceful shutdown in a .NET worker service to prevent data loss?

Graceful shutdown in a .NET worker service requires proper cancellation token management. This Skill demonstrates patterns to ensure services shut down cleanly without data loss by correctly handling cancellation tokens during the hosted service lifecycle.

How does dependency injection work with scoped services in a .NET hosted service?

Dependency injection for scoped services in a .NET hosted service requires explicit scope creation. This Skill addresses scoped service resolution to ensure dependencies are handled correctly without captive dependency issues within long-running background services.

Can I integrate health checks with .NET worker services for monitoring reliability?

Yes, you can integrate health checks with .NET worker services. This Skill provides best practices for adding observability through health checks to monitor the reliability and continuous operation of your hosted services.

Why does my .NET background service crash when processing a message queue?

A .NET background service processing a message queue may crash due to unhandled exceptions or improper scoped service resolution. This Skill provides exception handling patterns to ensure service stability and reliability during queue processing.