background-services

Installation
SKILL.md

Background Services in ASP.NET Core

Rationale

Background services are essential for offloading work from the request pipeline, processing queues, and handling scheduled tasks. Poorly implemented background services can lead to data loss, orphaned jobs, and resource leaks. These patterns ensure reliable, observable, and gracefully degrading background processing in production applications.


BackgroundService vs IHostedService

Feature BackgroundService IHostedService
Purpose Long-running loop or continuous work Startup/shutdown hooks
Methods Override ExecuteAsync Implement StartAsync + StopAsync
Lifetime Runs until cancellation or host shutdown StartAsync runs at startup, StopAsync at shutdown
Use when Polling queues, processing streams, periodic jobs Database migrations, cache warming, resource cleanup

Related skills

More from wshaddix/dotnet-skills

Installs
22
GitHub Stars
23
First Seen
Mar 7, 2026