【发布时间】:2017-02-04 17:04:44
【问题描述】:
我在我的 WebApi 应用程序中使用 Hangfire 和 Hangfire.MemoryStorage。
我在自己的 startup.cs 中配置了 Hangfire:
Hangfire.GlobalConfiguration.Configuration.UseMemoryStorage();
app.UseHangfireServer();
我尝试在控制器中使用作业激活
var jobId = BackgroundJob.Schedule(
() => ForceMissionEmail(mission.Guid),
TimeSpan.FromSeconds(10));
代码运行没有错误,但 10 秒后没有调用 ForceMissionEmail 方法。
【问题讨论】:
-
尝试在 IBackgroundJobClient 上使用 Enqueue 方法来测试 Hangfire 是否设置正确。
-
enqueue 不会抛出错误,但我的方法没有被调用 var jobId = BackgroundJob.Enqueue(() => ForceMissionEmail(mission.Guid));
-
我认为你应该尝试添加一个控制台记录器docs.hangfire.io/en/latest/configuration/…
标签: c# asp.net-web-api owin autofac hangfire