c# – asp.net cron job quartz.net bug,总是没有触发

我有一份工作,每30分钟触发一次.当工作开火时,我设置了一个测试表并记录信息.例如 :

2015-12-13 19:30:00.043
2015-12-14 12:30:00.043
2015-12-14 13:00:00.043
2015-12-14 16:00:00.043

但是你可以看到它不会每30分钟触发一次. 19:30然后12:30 ..我注意到如果我打开管理工作室并查看此表,下一份工作将触发100%.为什么会发生这种情况,是quartz.net错误吗?
P.S我正在使用asp.net mvc,这是代码:

  ITrigger trigger = TriggerBuilder.Create()
                   .WithDailyTimeIntervalSchedule
                     (s =>
                        s.WithIntervalInMinutes(30)
                        .OnEveryDay()
                       .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 0))
                     )
                   .Build();

               scheduler.ScheduleJob(job, trigger);

最佳答案 需要将WithDailyTimeIntervalSchedule更改为WithSimpleSchedule.警告:可能有更好的方法来处理startDate.

DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0 ,0, DateTimeKind.Utc);

 ITrigger trigger = TriggerBuilder.Create()
.StartAt(new DateTimeOffset(startDate, new TimeSpan(0)))
.WithSimpleSchedule
(s =>
    s.WithIntervalInMinutes(30)
    .RepeatForever()
)                   
.Build();

测试:

var times = TriggerUtils.ComputeFireTimes(trigger as IOperableTrigger, null, 10);

foreach (var time in times)
    Console.WriteLine(time.UtcDateTime);

Console.ReadKey();

结果:

14.12.2015 15:00:00
14.12.2015 15:30:00
14.12.2015 16:00:00
14.12.2015 16:30:00
14.12.2015 17:00:00
14.12.2015 17:30:00
14.12.2015 18:00:00
14.12.2015 18:30:00
14.12.2015 19:00:00
14.12.2015 19:30:00
点赞