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)
});
}

上一篇:uwsgi


下一篇:linux基础之nginx 详述03