Quartz job stop if it is already running
Khalid Salameh
1
Reputation point
Hello,
I have a job with a for loop, job keep checking pending applications to send it to WCF service, some times the for loop not finished but the second job started, in this case I got duplicate applications because it is exist in first loop and second loop.
I need to stop the code/loop at all in first job once time of second job starting
int everyMinutes = Convert.ToInt32(WebConfigurationManager.AppSettings["Scheduler__Minutes"]); // 3 minutes
//** Pause current job, so it won't fire again while executing.
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
IJobDetail job = JobBuilder.Create<ApplicationsJob>().Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("AppJob", "Group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(everyMinutes )
.RepeatForever())
.Build();
scheduler.ScheduleJob(job, trigger);
Thanks
Sign in to answer