我是Quartznet调度程序的新手。我正在努力实施 “CalendarIntervalTriggerImpl”触发器。我设定了一个过去的日期(一天 2010年)触发。
当我通过传递Jobdetail来调用ScheduleJob方法时 &安培;触发器,它立即触发Job.Execute方法。不管我 我错过了什么。请以正确的方式指导我。
请查看以下示例代码
class Program
{
private static IScheduler _scheduler;
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now.Day);
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
_scheduler = schedulerFactory.GetScheduler();
_scheduler.Start();
AddJob();
}
public static void AddJob()
{
IJob myJob = new MyJob(); //This Constructor needs to be parameterless
JobDetailImpl jobDetail = new JobDetailImpl("Group1", "Group1", myJob.GetType());
CalendarIntervalTriggerImpl trigger = new CalendarIntervalTriggerImpl("Group1", "Group1", IntervalUnit.Week, 2);
trigger.StartTimeUtc = DateTime.Now.AddDays(-3).AddSeconds(15);
_scheduler.ScheduleJob(jobDetail, trigger);
Console.WriteLine("Next : {0}", trigger.GetNextFireTimeUtc().Value.ToLocalTime());
}
}
internal class MyJob : IJob
{
public void Execute(IJobExecutionContext context)
{
Console.WriteLine("Executing the job...");
}
}
答案 0 :(得分:0)
如果您未设置misfire指令,则这是默认行为。将其设置为DoNothing,即2。