Jay*_*Sun 5 quartz.net topshelf
阅读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);
});
}
Run Code Online (Sandbox Code Playgroud)
小智 8
我相信你遇到问题的原因是因为你正在使用
x.ScheduleQuartzJobAsService
Run Code Online (Sandbox Code Playgroud)
代替
x.ScheduleQuartzJob
Run Code Online (Sandbox Code Playgroud)
我刚刚第一次使用Quartz,但我有20个不同的计划在同一个主机上运行
在 Topshelf-Quartz 集成上创建第二个服务或平底船,并拥有一个初始化两个 Quartz 实例并将其关闭的服务。
根据设计,Topshelf 将仅托管单个[服务]进程。如果 Topshelf 托管多个进程,您将无法对内容进行任何有用的管理或监控。它最终会成为一种不可持续的模式。
| 归档时间: |
|
| 查看次数: |
4904 次 |
| 最近记录: |