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();
The problem with the above code is that StartNow
is not working. It runs normally but only after 2 hours. I can't run it immediately.
StartNow
is working with WithSimpleSchedule
but not with .WithDailyTimeIntervalSchedule
Looks like WithDailyTimeIntervalSchedule
is not what you need. If you specify start time = 8 AM, end time = 11 PM, interval = 2 hours, jobs will be scheduled to run exactly at 8 AM, 10 AM, 12 PM, 2 PM, 4 PM, 6 PM, 8 PM and 10 PM.
As a solution you can create two triggers:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.