Quartz.Net系列(十二):六大Calendar(Annual、Cron、Daily、Holiday、Monthly、Weekly)

示例:在一天当中的13:00到14:00不要执行

public async static Task Test() { var scheduler = await StdSchedulerFactory.GetDefaultScheduler(); await scheduler.Start(); DailyCalendar dailyCalendar = new DailyCalendar(DateBuilder.DateOf(13,0,0).DateTime, DateBuilder.DateOf(14,0,0).DateTime); var job = JobBuilder.Create<MyJob>().WithIdentity("MyJob").Build(); var trigger = TriggerBuilder.Create().WithDailyTimeIntervalSchedule( d => d.OnEveryDay() .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(8, 30)) .EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(22, 00)) .WithIntervalInSeconds(1) ) .ModifiedByCalendar("myCalendar") .Build(); await scheduler.AddCalendar("myCalendar", dailyCalendar, true,true); await scheduler.ScheduleJob(job, trigger); }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyyfpw.html