参考文档
1 HELLOWORLD程序
实现每个五秒自动执行某个任务
public class Program { public static void Main() { Run(); Console.ReadLine(); } public async static Task Run() { // 1.创建scheduler的引用 ISchedulerFactory schedFact = new StdSchedulerFactory(); IScheduler sched = await schedFact.GetScheduler(); //2.启动 scheduler await sched.Start(); // 3.创建 job IJobDetail job = JobBuilder.Create<SimpleJob>() .WithIdentity("job1", "group1") .Build(); // 4.创建 trigger ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trigger1", "group1") .WithSimpleSchedule(x => x.WithIntervalInSeconds(5).RepeatForever()) .Build(); // 5.使用trigger规划执行任务job await sched.ScheduleJob(job, trigger); Console.WriteLine("I am here"); } } public class SimpleJob : IJob { public virtual Task Execute(IJobExecutionContext context) { Thread.Sleep(10000); return Console.Out.WriteLineAsync($"job工作了 在{DateTime.Now}"); } }View Code
2.
标签:教程,Quartz,Console,await,job,trigger,使用,sched,public From: https://www.cnblogs.com/noigel/p/17159746.html