您使用零线程调度程序来安排作业。例如调度初始化代码:
var properties = new NameValueCollection();
properties["quartz.scheduler.instanceId"] = "AUTO";
properties["quartz.threadPool.type"] = "Quartz.Simpl.ZeroSizeThreadPool, Quartz";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = tablePrefix;
properties["quartz.jobStore.clustered"] = "false";
properties["quartz.dataSource.default.connectionString"] = connectionString;
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
schedFactory = new StdSchedulerFactory(properties);
BaseScheduler = schedFactory.GetScheduler();
例如调度功能:
protected ITrigger CreateSimpleTrigger(string tName, string tGroup, IJobDetail jd, DateTime startTimeUtc,
DateTime? endTimeUtc, int repeatCount, TimeSpan repeatInterval, Dictionary<string, string> dataMap,
string description = "")
{
if (BaseScheduler.GetTrigger(new TriggerKey(tName, tGroup)) != null) return null;
var st = TriggerBuilder.Create().
WithIdentity(tName, tGroup).
UsingJobData(new JobDataMap(dataMap)).
StartAt(startTimeUtc).
EndAt(endTimeUtc).
WithSimpleSchedule(x => x.WithInterval(repeatInterval).WithRepeatCount(repeatCount)).
WithDescription(description).
ForJob(jd).
Build();
return st;
}
很显然,你需要提供你的UI所有相关领域,并从这些领域进入函数传递值。一些必填字段的示例屏幕截图:

你的Windows服务将初始化处理通信(多线程调度)在一个非常相似的方式的方式方法零线程调度上面和多初始化线程调度程序将监视数据库中的所有触发器,并按照这些触发器中的指定开始工作。 Quartz.net将在这方面做所有的重要工作。一旦您安排了作业和触发器在数据库中,您只需要初始化该多线程调度程序,将其连接到包含触发器的数据库,并且只要该服务正在运行,它就会继续触发这些作业并执行您的代码。
谢谢院长。对不起,前往不同的时区,所以有点晚回复。解决方案很有意义。就我的工作而言,在我的WPF应用程序中,我只是创建作业详细信息和触发器详细信息,并在调度器上调用ScheduleJob,调度器应存储作业并触发Quartz数据库表中的详细信息。然后从Windows服务中获得调度程序并调用Scheduler.Start方法来运行它们的作业。对? – Maverick0208
正确的,一旦你初始化你的调度程序并调用Start()它将监视你的数据库并执行任何预定的作业... –
再次感谢。 – Maverick0208