quartz顺序执行任务
//创建计划链表 JobChainingJobListener listener = new JobChainingJobListener("JobLink"); IJobDetail j1 = JobBuilder.Create() .WithIdentity("j1", "jg1") .OfType(typeof(Job1Type)) .Build(); IJobDetail j2 = JobBuilder.Create() .WithIdentity("j2", "jg1") .StoreDurably(true) //持久存放设置为true,这一步很重要,不然Job2只会执行一遍 .OfType(typeof(Job2Type)) .Build(); ITrigger trigger = TriggerBuilder.Create() .WithIdentity("t1", "tg1") .WithCronSchedule("0/2 * * * * ? ") .StartNow() .Build(); //将Job2添加到调度器 await _scheduler.AddJob(j2, false, true); //设置执行顺序为先执行Job1再执行Job2 listener.AddJobChainLink(j1.Key, j2.Key); //调度器使用计划链表 _scheduler.ListenerManager.AddJobListener(listener); //安排调度作业 await _scheduler.ScheduleJob(j1, trigger);