SiberianGuy
SiberianGuy

Reputation: 25312

Execute Job only after previous one has been executed

I have a job that is scheduled to execute every minute:

        var trigger = TriggerBuilder.Create().
            StartNow().
            WithSimpleSchedule(x => x.WithIntervalInMinutes(1).RepeatForever()).
            Build();

But sometimes it takes for the job more than one minute to be executed. So the next job is started till the previous is finished and it results into some conflicts.

Is it possible to tell to Quartz.Net schedule to run a job every minute but only if the previous job has already finished?

Upvotes: 8

Views: 4645

Answers (1)

Jongyu Lin
Jongyu Lin

Reputation: 631

If you're using Quartz 2.x, you need to decorate your job class with DisallowConcurrentExecutionAttribute. Something like the below:

[Quartz.DisallowConcurrentExecutionAttribute()]
public class HelloJob : IJob
...

This is addressed in the FAQ under "How do I keep a Job from firing concurrently?" http://www.quartz-scheduler.net/documentation/faq.html

Upvotes: 17

Related Questions