Program.cs
982 Bytes
using Quartz.Impl;
using Quartz;
using HH.Mes.Tool.Jobs;
using HH.Mes.Tool.Utils;
using Quartz.Logging;
namespace HH.Mes.Tool
{
internal class Program
{
static void Main(string[] args)
{
LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());
var schedulerFactory = new StdSchedulerFactory();
var scheduler = schedulerFactory.GetScheduler().GetAwaiter().GetResult();
//创建作业和触发器
var jobDetail = JobBuilder.Create<TestJob>().Build();
var trigger = TriggerBuilder.Create()
.WithSimpleSchedule(x => x.WithInterval(TimeSpan.FromSeconds(10)).RepeatForever())
.Build();
//添加调度
scheduler.ScheduleJob(jobDetail, trigger).Wait();
scheduler.Start();
Console.WriteLine($"任务调度器已启动");
Console.ReadLine();
scheduler.Shutdown();
}
}
}