Reputation: 362
Let's say we have a job and corresponding trigger configured as follows:
var jobKey = new JobKey(typeof(HelloJob).Name, typeof(HelloJob).Name);
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity(jobKey)
.RequestRecovery()
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(string.Format("{0}Trigger", typeof(HelloJob).Name), typeof(HelloJob).Name)
.StartAt(DateBuilder.FutureDate(1, IntervalUnit.Second))
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(1)
.WithRepeatCount(9))
.Build();
using "quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz".
Well I expect the job execute 10 times in normal situation and of course it does. The problem is that I want the job to continue the remaining repeat count if any stop occurres during its life cycle.
For example I stop the program when the fifth execution of the job is done and the next time that I run the program I want to execute the job only five times more but it is executed 10 times.
How should I configure Scheduler, Job and Trigger in order to do this?
Upvotes: 1
Views: 1807
Reputation: 476
Make sure the database objects are created and configure jobstores.
Look this example. It can help you.
https://github.com/Leftyx/QuartzNetAdoJobStoreSQLite
Upvotes: 1
Reputation: 49809
You may do this by storing remaining count between program execution:
.WithRepeatCount()
instead of constant.Upvotes: 1