Console.WriteLine(DateTime.Now);
//1.首先创建一个作业调度池
ISchedulerFactory schedf = new StdSchedulerFactory();
IScheduler sched = schedf.GetScheduler();
//2.创建出来一个具体的作业
IJobDetail job = JobBuilder.Create<JobDemo>().Build();
//任务一时间
DateTimeOffset startTime1 = DateBuilder.NextGivenSecondDate(DateTime.Now.AddSeconds(20), 2);
DateTimeOffset startTime2 = DateBuilder.NextGivenSecondDate(DateTime.Now.AddSeconds(20), 2);
//任务二
//3.创建并配置一个触发器
ISimpleTrigger trigger = (ISimpleTrigger)TriggerBuilder.Create().StartAt(startTime1).EndAt(endTime1).WithSimpleSchedule(x => x.WithIntervalInSeconds(5).WithRepeatCount(int.MaxValue)).Build();
//4.加入作业调度池中
sched.ScheduleJob(job, trigger);
//5.开始运行
sched.Start();
Console.ReadKey();