//创建计划链表 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);
标签:WithIdentity,quartz,Create,j1,j2,任务,顺序,Build,scheduler From: https://www.cnblogs.com/Insist-Y/p/16776955.html