c# Quartz 启动定时任务后不要立即执行
想整个定时预警检测任务,想每隔5分钟检测一次,但发现这个Quartz启动后,会立即执行一次,但我不想马上执行,想5分钟后再执行
百度了Java的有个WithMisfireHandlingInstrucionDoNothing方法,但c#里面没有,我试了全部WithMisfireHandlingInstrucionXXXX方法,都没用,都会立即执行
后面只能用startAt处理了,如果网友有其它方法,可在评论教下我
var _scheduler = await StdSchedulerFactory.GetDefaultScheduler(); var jobKey = new JobKey(nameof(ForwardStatusWarnJob)); await _scheduler.DeleteJob(jobKey); if (!await _scheduler.CheckExists(jobKey)) { var job = JobBuilder.Create<ForwardStatusWarnJob>().WithIdentity(jobKey).StoreDurably().Build(); await _scheduler.AddJob(job, true); } var trigger = TriggerBuilder.Create() .ForJob(jobKey) .WithSimpleSchedule(b => { b .WithIntervalInMinutes(5) .RepeatForever(); }) .StartAt(DateTimeOffset.Now.AddMinutes(5)) .Build(); await _scheduler.ScheduleJob(trigger); await _scheduler.Start();