[英]Hangfire ASP.NET Core packages
我已經安裝了包:
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
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.