.NET CORE中使用Hangfire执行定时任务,同时可通过Hangfire Dashboard 查询job执行情况。体验非常好。
代码里添加Hangfire
builder.Services.AddHangfireServer();
app.UseHangfireDashboard("/hangfire",new DashboardOptions() {
Authorization = new List<CustomAuthorizeFilter> { new CustomAuthorizeFilter() }
});
RecurringJob.AddOrUpdate<JobsController>("test", x => x.TestUser(), Cron.Hourly(), new RecurringJobOptions
{
TimeZone = TimeZoneInfo.Local
});