AI OnAI Off
IScheduledJobExecutor.Cancel() will not immediately kill the scheduled job, but only call job.Stop().
In order for this to work:
- Your job must be stoppable. (IsStoppable returns true)
- Your job must actually stop, if asked to. (Continously checking if .Stop() is called, and then stop executing)
Code example:
https://www.gulla.net/no/blog/episerver-scheduled-jobs-stop-and-restart/
Hi Ritu,
If you are doing some iterations using for/foreach etc.. then make sure you are calling stop method in that loop itself.
Thanks Tomas and Ravindra!
I believe we've missed the stop check in one of the many loops we have in the job logic, which is not letting it stop this way. Will add that.
Regards
Ritu
Hi
I'm using IScheduledJobRepository to lookup a job and then calling IScheduledJobExecutor.Cancel(id) to stop this job if running, but it's not working. The job keeps running. This logic is not throwing any errors/exceptions either.
Any thoughts on what may be wrong?
Regards
Ritu