1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using Quartz;
- using Quartz.Impl;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- ISchedulerFactory sf = new StdSchedulerFactory();
- IScheduler sched = sf.GetScheduler(); //创建调度实例
- sched.Start(); //开启调度
- //aa();
- //bb();
- Console.WriteLine("启动成功 ");
- Console.ReadKey();
- }
- private static void aa()
- {
- ISchedulerFactory sf = new StdSchedulerFactory();
- IScheduler scheduler = sf.GetScheduler(); //创建调度实例
- //创建任务实例
- IJobDetail job = JobBuilder.Create<Class1>().WithIdentity(new JobKey("job1")).Build();
- //创建触发器实例
- ITrigger trigger = TriggerBuilder.Create().StartAt(DateTime.Now.AddSeconds(0)).WithCronSchedule("0/5 * * * * ? ").Build();
- scheduler.ScheduleJob(job, trigger); //绑定触发器和任务
-
- scheduler.Start(); //启动监控
- }
- private static void bb()
- {
- ISchedulerFactory sf = new StdSchedulerFactory();
- IScheduler scheduler = sf.GetScheduler(); //创建调度实例
- //创建任务实例
- IJobDetail job = JobBuilder.Create<Class2>().WithIdentity(new JobKey("job2")).Build();
- //创建触发器实例
- ITrigger trigger = TriggerBuilder.Create().StartAt(DateTime.Now.AddSeconds(0)).WithCronSchedule("0/10 * * * * ? ").Build();
- scheduler.ScheduleJob(job, trigger); //绑定触发器和任务
- }
- }
- }
|