This method does not seem to work.
The only solution I found was to complete all the tasks:
var groups = sched.JobGroupNames; for (int i = 0; i < groups.Length; i++) { string[] names = sched.GetJobNames(groups[i]); for (int j = 0; j < names.Length; j++) { var currentJob = sched.GetJobDetail(names[j], groups[i]); } }
When a job is found, it means that it is still active. If you set your work to be durable , however, it will never be deleted if there is no corresponding trigger.
In this situation, this code works better:
var groups = sched.JobGroupNames; for (int i = 0; i < groups.Length; i++) { string[] names = sched.GetJobNames(groups[i]); for (int j = 0; j < names.Length; j++) { var currentJob = sched.GetJobDetail(names[j], groups[i]); if (sched.GetTriggersOfJob(names[j], groups[i]).Count() > 0) {
UPDATE
I did some debugging to find out what happens with GetCurrentlyExecutingJobs() .
It actually returns the job in progress, but the items are removed from the collection as soon as the job is completed.
You can test 2 functions JobToBeExecuted and JobWasExecuted in the QuartzScheduler class.
source share