Quartz net Scheduler -Schedule Job

时间:2011-08-23 02:56:29

标签: quartz.net

我应该做一个简单的任务。我创建了一个新作业,如果持久化,则使用IScheduler.AddJob方法添加add。这份工作已经注册,但就我而言,我无法想象如何为它分配触发器。

1 个答案:

答案 0 :(得分:1)

这来自tutorial

// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();

// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();

// construct job info
JobDetail jobDetail = new JobDetail("myJob", null, typeof(DumbJob));
// fire every hour
Trigger trigger = TriggerUtils.MakeHourlyTrigger();
// start on the next even hour
trigger.StartTime = TriggerUtils.GetEvenHourDate(DateTime.UtcNow);  
trigger.Name = "myTrigger";
sched.ScheduleJob(jobDetail, trigger);