【发布时间】:2014-01-22 21:46:34
【问题描述】:
在此处阅读有关 Topshelf 集成的文档:https://github.com/dtinteractive/Topshelf.Integrations
看起来它应该像在HostFactory 中安排多个石英作业一样简单,但看起来第二个预定作业是唯一正在运行的作业。
我不确定如何从这里开始。但我需要安排两个按不同时间表运行的作业。第一个应该每天运行,第二个每小时运行一次。
static void Main(string[] args)
{
HostFactory.Run(x =>
{
x.ScheduleQuartzJobAsService(q =>
q.WithJob(() => JobBuilder.Create<TmsIdImportTask>().Build())
.AddTrigger(() =>
TriggerBuilder.Create()
.WithSimpleSchedule(builder => builder
.WithIntervalInMinutes(Int32.Parse(ConfigurationManager.AppSettings["ScheduleImportFrequencyInMinutes"]))
.RepeatForever()).Build())
);
x.ScheduleQuartzJobAsService(q =>
q.WithJob(() => JobBuilder.Create<ImportTmsXMLTask>().Build())
.AddTrigger(() => TriggerBuilder.Create().WithSimpleSchedule(builder =>
builder.WithIntervalInMinutes(Int32.Parse(ConfigurationManager.AppSettings["TMSImportFrequencyInMinutes"]))
.RepeatForever()).Build())
);
x.RunAsLocalSystem();
var description = ConfigurationManager.AppSettings["ServiceDescription"];
x.SetDescription(description);
var displayName = ConfigurationManager.AppSettings["ServiceDisplayName"];
x.SetDisplayName(displayName);
var serviceName = ConfigurationManager.AppSettings["ServiceName"];
x.SetServiceName(serviceName);
});
}
【问题讨论】:
-
你不能把 Quartz 初始化放在你的服务类
Start()中并关闭Stop()方法吗?为什么要使用这种集成?
标签: quartz.net topshelf