Quartz job stop if it is already running

Khalid Salameh 1 Reputation point
2022-11-06T12:23:40.367+00:00

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

ASP.NET MVC
ASP.NET MVC
A Microsoft web application framework that implements the model-view-controller (MVC) design pattern.
854 questions
{count} votes