防止石英立即着火.净的事件
本文关键字:事件 石英立 | 更新日期: 2023-09-27 17:53:22
当我创建一个简单的触发器并将其分配给调度程序时,它会立即触发,然后在预定的间隔内再次触发。如何使它只在指定的时间开火?
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
// construct job info
JobDetail jobDetail = new JobDetail("myJob", "Default", typeof(DumbJob));
// Example trigger to fire after 1 minute, no repeat
Trigger trigger = TriggerUtils.MakeMinutelyTrigger(1, 0);
// Schedule the job
trigger.Name = "demoTrigger";
sched.ScheduleJob(jobDetail, trigger);
sched.Start();
public class DumbJob : IJob
{
public DumbJob()
{
}
public void Execute(JobExecutionContext context)
{
MessageBox.Show("Dumb job is running");
}
}
触发器对象有一个StartTimeUtc属性,你可以用它来指定触发器何时开始触发等等。下面是一个例子:
trigger.StartTimeUtc = TriggerUtils.GetEvenMinuteDate(DateTime.Now.AddMinutes(1));
这将创建一个触发器,它将在下一个偶数分钟开始触发。