1.先在bin文件夹中引用Quartz.Net的dll 文件
Common.Logging.dll,Quartz.dll
2.Global文件中的Application_Start。
//从配置中读取任务启动时间
int indexStartHour = Convert.ToInt32(ConfigurationManager.AppSettings["IndexStartHour"]);
int indexStartMin = Convert.ToInt32(ConfigurationManager.AppSettings["IndexStartMin"]);
ISchedulerFactory sf = new StdSchedulerFactory();//执行者
sched = sf.GetScheduler();
JobDetail job = new JobDetail("job1", "group1", typeof(TestJob));//TestJob为实现了IJob接口的类,(工作名称,分组,那个类)
Trigger trigger = TriggerUtils.MakeDailyTrigger("tigger1", indexStartHour, indexStartMin);//每天10点00分执行
trigger.JobName = "job1";
trigger.JobGroup = "group1";
trigger.Group = "group1";
sched.AddJob(job, true);
sched.ScheduleJob(trigger);
sched.Start();
3.Application_End时
sched.Shutdown(true);//结束时关掉
4.具体要执行的代码在TestJob中的 public void Execute(JobExecutionContext context)方法中