How to send cancellation token to terminate recurring jobs that are running every second


I am launching a background recurring job using the following API
RecurringJob.AddOrUpdate( () => Cancelable( JobCancellationToken.Null), Cron.Minutely);

My goal is to stop all the processing and recurring jobs when the service is terminated. This
can be also done by selecting the “Delete” button in the dashboard.

For some reason, when I delete the task through dash board, the cancellationtoken is not
set to true . How do I capture the jobID or the processing or the recurring job?

I have used var recurring = connection.GetRecurringJobs().FirstOrDefault(p => p.Id == “HangFireService.Cancelable”);

How do we terminate processing jobs . Please let me know.


Call IJobCancellationToken.ThrowIfCancellationRequested() periodically in your job.

It does not work as the token is set to false all the time… Can you provide me more details

RecurringJob.AddOrUpdate( () => Cancelable( JobCancellationToken.Null), Cron.Minutely);

How do I trigger the deletion of the jobs without the dashboard… Like I want kill all the jobs when I kill the service
in the console application.


When I exit the service, is it sufficient that I just kill the recurring job and not the ones that are processing as I do not want any tasks hanging in the background . thanks