我已经安装了软件包:Hangfire.AspNetCore
Hangfire.MemoryStorage.Core
这是我的代码:
using Hangfire;
using Hangfire.MemoryStorage;
public void ConfigureServices(IServiceCollection services)
{
services.AddHangfire(c => c.UseStorage(GlobalConfiguration.Configuration.UseMemoryStorage()));
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseHangfireServer();
}
...
public static void Main(string[] args)
{
RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Minutely);
}
但是,我得到了错误:
JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.
我的应用程序正在
ASP.NET Core
上运行。 最佳答案
Main
方法在Configure
和ConfigureServices
之前运行,因此您尝试在配置之前先使用Hangfire
。
关于c# - Hangfire ASP.NET Core套件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53927076/