安装quartz包版本2.6.1
1 public class TimingJob : IJob 2 { 3 public void Execute(IJobExecutionContext context) 4 { 5 //将要定时执行的逻辑代码写于此处 6 systemState = false; 7 } 8 }
1 ISchedulerFactory sf = new StdSchedulerFactory(); 2 IScheduler scheduler = sf.GetScheduler(); 3 4 IJobDetail job = JobBuilder.Create<TimingJob>().WithIdentity("job1", "mygroup").Build(); 5 6 ITrigger trigger = TriggerBuilder.Create().StartAt(DateTime.Now.AddSeconds(5)).WithCronSchedule("0 0 1/3 * * ? ").Build(); 7 8 scheduler.ScheduleJob(job, trigger); 9 scheduler.Start(); 10 11 QuartzState = true;
时间(Cron)表达式:https://www.cnblogs.com/-sylar/p/8367625.html
在线Cron表达式生成器:http://cron.qqe2.com/