Hangfire 1.7.0之后版本支持秒级定时任务
作者:互联网
但是有坑,就是,其默认后台检测机制默认是15s秒执行,也就是说,即使设置每秒执行,也会15秒后执行,这时候我们需要在注入构造时,设置默认的轮询参数:
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var service = context.ServiceProvider;
app.UseHangfireServer(options: new BackgroundJobServerOptions
{
//检测时间
SchedulePollingInterval = TimeSpan.FromMilliseconds(1000),
//心跳时间
HeartbeatInterval = TimeSpan.FromMilliseconds(1000),
//总工作数
WorkerCount = Math.Max(Environment.ProcessorCount, 10)
});
}
标签:FromMilliseconds,1.7,TimeSpan,app,Hangfire,默认,秒级,context,var 来源: https://www.cnblogs.com/6-ziyu/p/15532674.html