我正在尝试使用 Hangfire 在后台运行一个循环作业,从另一个网站轮询数据,问题是如果之前的作业仍在运行,我不希望循环作业运行。
我通读了文档,但似乎找不到答案。有没有一种方法可以使每 10 分钟运行一次的循环作业在上一个任务尚未完成时跳过?
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
// Hangfire
GlobalConfiguration.Configuration
.UseSqlServerStorage("DatabaseContext");
app.UseHangfireDashboard();
app.UseHangfireServer();
RecurringJob.AddOrUpdate("site-parser", () => SiteParserService.RunAll(), Cron.Minutely, TimeZoneInfo.Utc);
ConfigureAuth(app);
}
最佳答案
你可以使用;
[DisableConcurrentExecution(10 * 60)]
作业方法上的属性。
您可以在此处找到有关此属性的信息: http://odinserj.net/2014/05/21/hangfire-0.8.2-released/
关于c# - Hangfire 单实例重复作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30787584/