MVC中使用Hangfire按秒执行任务
1、更新Hangfire版本到1.7.0,,才支持使用按秒循环任务执行
RecurringJob.AddOrUpdate("test",()=>writeLog("每20秒执行任务"), "*/20 * * * * *");
2、
修改参数
var jobOptions = new BackgroundJobServerOptions
{
Queues = new[] { "critical", "test", "default" },
WorkerCount = Environment.ProcessorCount * int.Parse(Configuration["Hangfire:ProcessorCount"]),
ServerName = Configuration["Hangfire:ServerName"],
SchedulePollingInterval = TimeSpan.FromSeconds(1), //计划轮询间隔 支持任务到秒
};
https://github.com/18965824402/dotnet-core-Example/tree/master/hangfiretest
MVC中使用Hangfire按秒执行任务
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/42607.html