In Quartz.NET is there a way to set a property that will only allow one instance of a Job to run?

后端 未结 4 1446
死守一世寂寞
死守一世寂寞 2020-12-24 11:44

I have a service that will run every X minutes. If that job takes longer than X minutes for some unforeseen reason I want to make sure that the trigger doesn\'t kick off a s

4条回答
  •  萌比男神i
    2020-12-24 12:21

    public bool Validar(IJobExecutionContext context) {

            if (context.Scheduler.GetCurrentlyExecutingJobs().Any(x => x.FireInstanceId != context.FireInstanceId
             && x.JobDetail.Key == context.JobDetail.Key))
            {
                return true;
            }
            else
            {
                return false;
            }
    
        }
    

提交回复
热议问题