This console application demonstrates the use of GenericHost
as known WorkerService
.
You can find a few examples of running background jobs in different ways.
HostBuilder
is a lightweight version of theWebHostBuilder
and it does not process HTTP requests.HostBuilder
similarly like theWebHostBuilder
, allows to configure services, using dependency injection, HttpClientFactory, logging + Serilog and so on.
- Publish the application with the predefined PublishAsWinService.pubxml (c:\svc)
- Run the WinServiceCommands.bat file (create, start, stop, delete functions)
- PrinterService: a simple example of using
BackgroundService
as a base class. - FileWriterService: a simple example of using
IHostedService
and a Timer in it. Quartz
: using the Quartz-scheduler / Quartz.NET to create background process timing with cron expression.- Use the
System.Threading.Channels
library to create a bounded channel/in-memory queue by utilizing IAsyncEnumerable. - Example of scheduling repeating tasks π½οΈ12min-NickChapsas using PeriodicTimer.
- Example of Producer-Consumer pattern with TPL Dataflow.
- Azure Application Insights for WorkerService π€My repository.
- Hangfire example π€My repository.
- π Microsoft:
- IHostedLifecycleService interface in .NET 8 πSteve Gordon
- Schedule Jobs with Quartz.NET πCode-Maze
- Scheduling background tasks with Quartz π½οΈ11min-Milan (nice solution by using IConfigureOptions)
- Too many timers in .NET πMeziantou - GΓ©rald BarrΓ©
- π Andrew Lock
- System Threading Channels
- System.Threading.Channels Namespace πMicrosoft-Learn
- Introduction to System.Threading.Channels πSteve Gordon
- Exploring System.Threading.Channels πNicolas Portmann
- Producer-Consumer application with Channels πCode-Maze
- TPL Dataflow
- Implementing the producer-consumer pattern with TPL Dataflow πMark Heath
- Task Parallel Library (TPL) πMicrosoft-Learn
- Implement a producer-consumer dataflow pattern πMicrosoft-Learn
- Coravel (Task Scheduling, Caching, Queuing, Event Broadcasting)
- Easiest scheduling with Coravel π½οΈ11 min - NickChapsas
- Scheduled job with Worker Service πJames Hickey