1.DisallowConcurrentExceution
从字面意思来看也就是不允许并发执行
简单的演示一下
[DisallowConcurrentExecution] public class TestDisallowConcurrentExectionJob : IJob { public async Task Execute(IJobExecutionContext context) { await Task.Run(() => { var nextTime = context.NextFireTimeUtc?.ToLocalTime(); var currentTime = DateTime.Now; Console.WriteLine($"CurrentTime={currentTime}, FireTime={context.ScheduledFireTimeUtc?.ToLocalTime()}, NextTime={nextTime}"); }); Thread.Sleep(10000); } } public class TestDisallowConcurrentExectionScheduler { public async static Task Test() { var scheduler = await StdSchedulerFactory.GetDefaultScheduler(); await scheduler.Start(); var job = JobBuilder.CreateForAsync<TestDisallowConcurrentExectionJob>() .WithIdentity("TestDisallowConcurrentExectionJob") .UsingJobData("myKey", "myValue") .Build(); var trigger = TriggerBuilder.Create() .WithSimpleSchedule(s => s.WithIntervalInSeconds(1) .RepeatForever()) .Build(); await scheduler.ScheduleJob(job, trigger); } }