A Quartz.NET scheduler runs background jobs according to triggers. It tracks schedules, creates job instances through a job factory, and executes them as a hosted background service. section 34.3 section 34.3.1
Quartz.NET coordinates four related pieces:
- Jobs implement the task logic through the IJob interface. section 34.3 section 34.3.1
- Triggers determine when jobs run, such as every five minutes or on a calendar schedule. section 34.3
- The job factory creates job instances and can retrieve implementations from dependency injection. section 34.3 section 34.3.1
- The hosted service starts the scheduler with the application and can wait for running jobs during shutdown. section 34.3.1
Listing 34.10 Configuring Quartz.NET
using Quartz;
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) => #1
{
services.AddQuartz(q => #2
{
q. UseMicrosoftDependencyInjectionJobFactory(); #3
});
services.AddQuartzHostedService( #4
q => q.WaitForJobsToComplete = true); #4
})
.Build();
host.Run();
Configure Quartz.NET with dependency injection and register its hosted service; the scheduler then starts when the application starts. section 34.3.1











