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