Quartz.NET 記錄 (草稿)
阿新 • • 發佈:2020-11-22
public class JobSchedulerWork_Test { public static async void GetMESData() { //排程器工廠 ISchedulerFactory Work = new StdSchedulerFactory(); //排程器 IScheduler schedulers_work = await Work.GetScheduler(); await schedulers_work.GetJobGroupNames();/*-------------計劃任務程式碼實現------------------*/ //建立任務 IJobDetail job_Work = JobBuilder.Create<DataTesst>() .WithIdentity("TimeGetDataTest", "TimeGroupEMSTest") .Build(); //建立觸發器 每11點55分執行 //ITrigger TimeGetMESData = TriggerBuilder.Create().WithCronSchedule("0 55 11 * * ?").WithIdentity("TimeGetDataTest", "TimeGroupEMSTest").Build();//每五秒執行一次 ITrigger TimeGetMESData = TriggerBuilder.Create().WithIdentity("TimeGetDataTest", "TimeGroupEMSTest").WithCronSchedule("0/5 * * * * ?").Build();
//每9秒執行一次 //ITrigger TimeGetMESData = TriggerBuilder.Create().WithIdentity("TimeGetDataTest", "TimeGroupEMSTest").WithSimpleSchedule(t => t.WithIntervalInSeconds(90000).RepeatForever()).Build();//新增任務及觸發器至排程器中 await schedulers_work.ScheduleJob(job_Work, TimeGetMESData); /*-------------計劃任務程式碼實現------------------*/ //啟動 await schedulers_work.Start(); } }
學習Quartz.NET 待完善