using Quartz; using Quartz.Impl; public class StartJob { public readonly static StartJob Instance = new StartJob(); private StartJob() { } public async void Start() { // 创建调度器 IScheduler scheduler = await StdSchedulerFactory.GetDefaultScheduler(); await scheduler.Start(); string[] list = { "my", "your"}; foreach(string sub in list) { // 定义作业 IJobDetail job = JobBuilder.Create() .WithIdentity(sub + "Job") .SetJobData(new JobDataMap(Newtonsoft.Json.JsonConvert.DeserializeObject>("{\"" + sub + "test\":123,\"" + sub + "test2\":456}"))) .Build(); // 定义触发器 ITrigger trigger = TriggerBuilder.Create() .WithIdentity(sub + "Trigger") .StartNow() .WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever()) .Build(); // 调度作业 await scheduler.ScheduleJob(job, trigger); } } }