AddQuartzHostedService Task Cancellation
See original GitHub issueWhen I add Quartz hosted service via
services.AddQuartzHostedService(opt =>
{
opt.WaitForJobsToComplete = true;
});
and then shutdown my app how do my jobs know about app shutdown?
Say, I have a job like
public class DummyJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
while (!context.CancellationToken.IsCancellationRequested)
{
await Task.Delay(TimeSpan.FromSeconds(30), context.CancellationToken);
}
}
}
When the host is shut down I expect context.CancellationToken be cancelled. But it is not. So this job never finishes.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
c# - Quartz.net CancellationToken
According to the documentation, you should use Interrupt method to cancel Quartz jobs. ... Apply scheduler.Interrupt after the job executed and ...
Read more >Using Quartz.NET with ASP.NET Core and worker services
In this post I show how to run Quartz.NET jobs in ASP.NET Core and worker service apps using the Quartz.Extensions.Hosting package.
Read more >Microsoft DI Integration | Quartz.NET
The scheduling configuration will be checked against database and updated accordingly every time your application starts and schedule is being ...
Read more >Task Cancellation
In the Task classes, cancellation involves cooperation between the user delegate, which represents a cancelable operation, and the code that ...
Read more >ASP.NET Core scheduling with Quartz.NET and SignalR ...
This article shows how scheduled tasks can be implemented in ASP.NET Core using Quartz.NET and then displays the job info in an ASP....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks. It helped:
I’ve exposed some new configuration properties both via
SchedulerBuilder
and DI configuration.