views:

380

answers:

3

I've a job in Quartz.Net which triggers quite frequently, and sometimes runs for long, how do i cancel the trigger if the job is already running?

+1  A: 

Could you not just set some sort of global variable (jobRunning=true) when the job starts and revert it to false once it's finished?

Then when the trigger fires, just run your code if(jobRunning==false)

Paul
yes, often the simplest solutions are the best. i've implemented this, i though there were a implemented solution for this which paused the job until the first is done, but whatever, this works just fine!
Carl Hörberg
A: 

Your app could remove itself from the job list on startup and insert itself on shutdown.

Austin Salonen
+1  A: 

The more standard way is to use IInterruptableJob, see http://quartznet.sourceforge.net/faq.html#howtostopjob . Of course this is just another way to say if (!jobRunning)...

Marko Lahma
is only one instance of that class which implements IInterruptableJob allowed at a time, or a Job which uses that class?
Carl Hörberg
If you want to allow only one instance at a time then IStatefulJob is your fried, http://quartznet.sourceforge.net/faq.html#howtopreventconcurrentfire . IInterruptableJob just gives you a standard way to signal interrupt and you need to do the heavy-lifting on the job side (check if interrupted flag has been raised).
Marko Lahma