I have a Quartz job which is scheduled with a collection of triggers and it has 3 to 5 minutes of execution time. But at any moment in the future(it may be a week later or a couple of minutes later) I may need to reschedule it with a new trigger set. There will be some additions or deletions on trigger set.
How can I reschedule the job with new trigger set? The trick here is, I want to be sure that no instance of the job is alive at that moment, so I can reschedule my job reliably. Thanks for any help...
As I remember it, you can do:
List<JobExecutionContext> context = scheduler.GetCurrentlyExecutingJobs()
Iterate the list and call GetJobInstance() (or something similar) to find the job the context was created for, then check if it's the job you're interested in. If not, you can reschedule using the same trigger. Try something like this:
Trigger trigger = Global.scheduler.GetTrigger("testTrigger","triggerGroup");
trigger.set();
Global.scheduler.RescheduleJob(trigger.JobName, trigger.JobGroup, trigger);