Is the difference between AddQuartz and AddQuartzHostedService that the latter adds a hosted service?

345 Views Asked by At

I'm just learning Quartz.NET (and C# in general in fact) and I'm struggling to get my head around the differences between the AddQuartz and AddQuartzHostedService methods. From what I've seen here, here and here, it seems that AddQuartz adds and configures the Quartz scheduler, and AddQuartzHostedService explicitly adds this Quartz service (which I assume is the configured scheduler) as a hosted service... Have I got this right?

And in what context would I ever use AddQuartz if I don't intend to add it as a hosted service? Please help me clear up any misconceptions I might have. Thanks.

1

There are 1 best solutions below

3
Blindy On

AddQuartz configures the scheduling system by adding jobs and when they need to be called.

AddQuartzHostedService on the other hand sets up the scheduling system to run in the background as a hosted service, letting it run its jobs and (optionally) wait for any scheduled jobs before allowing the application to exit.

You always use both of them together.