I'm using Quartz
library to run a schedule task.I used it like this
ISchedulerFactory scheduleFact = new StdSchedulerFactory();
IScheduler scheduler = scheduleFact.GetScheduler();
scheduler.Start();
IJobDetail job = JobBuilder.Create<MyJob>()
.WithIdentity("myjob", "group 1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("mytrigger", "group 1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(60*60*12)
.RepeatForever())
.Build();
scheduler.ScheduleJob(job, trigger);
this works fine.that means the schedule runs for every 12 hours.but what I want is to run the task everyday when the time is 13.00.how can I do that.hope your help.
var trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule(s => s
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(13, 00)))
.EndingDailyAfterCount(1))
.Build();
Tipp: Output the next 10 runs on console for debugging purpose.
var times = TriggerUtils.ComputeFireTimes(trigger as IOperableTrigger, null, 10);
foreach (var time in times) Console.WriteLine(time);