Add a Resilient Periodic Background Worker to a .NET Generic Host
Run scheduled background work in a .NET generic host with graceful shutdown, cancellation-token delays, and basic failure handling.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Run scheduled background work in a .NET generic host with graceful shutdown, cancellation-token delays, and basic failure handling.
Replace ad-hoc threads with IHostedService and BackgroundService to run reliable background tasks that respect shutdown, handle scoped dependencies, and avoid crashing your .NET Core application.
Learn how to implement a cancellation-aware BackgroundService in ASP.NET Core, resolve scoped dependencies safely, and verify graceful shutdown.
Offload slow side work from ASP.NET Core endpoints using a bounded System.Threading.Channels queue and a BackgroundService worker — with the DI lifetime traps, graceful shutdown checks, and durability limits explained.