繁体   English   中英

Quartz.NET StartNow无法与WithDailyTimeIntervalSchedule一起使用

[英]Quartz.NET StartNow not working together with WithDailyTimeIntervalSchedule

            ITrigger trigger = TriggerBuilder.Create()
                                .WithIdentity("trigger1", "group1")
                                .WithDailyTimeIntervalSchedule(x => x
                                    .WithIntervalInHours(2)
                                    .OnEveryDay()
                                    .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(8, 0))
                                    .EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(23, 00)))
                                .StartNow()
                                .Build();

上面的代码的问题是StartNow无法正常工作。 它可以正常运行,但只能在2小时后运行。 我不能立即运行它。

StartNow正在使用WithSimpleSchedule但不能使用.WithDailyTimeIntervalSchedule

看起来WithDailyTimeIntervalSchedule不是您所需要的。 如果您指定开始时间= 8 AM,结束时间= 11 PM,间隔= 2小时,则作业将排定在8 AM,10 AM,12 PM,2 PM,4 PM,6 PM,8 PM和10下午。

作为解决方案,您可以创建两个触发器:

  1. 如果当前时间在上午8点至晚上11点之间,请创建触发,现在,现在+ 2小时,现在+ 4小时触发,并在今天晚上11点停止。
  2. 从下一个上午8点(今天或明天)开始,第二个触发器将在上午8点,上午10点等触发。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM