MVC中使用Hangfire按秒执行任务

冷暖自知 提交于 2019-12-05 19:08:15

 

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), //计划轮询间隔 支持任务到秒
};
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!