0

ASP.NET アプリケーションで hangfire.autofac 1.0.0 と共に hangfire 1.3.4 を使用する。次のシナリオがあります。

 class MyType : IDisposable 
 {
      public void Start()
      {
          RecurringJob.AddOrUpdate("background-update", () => ProcessData(), Cron.Daily());
          RecurringJob.Trigger("background-update"); 
      }

     public void ProcessData(){...}

     public void Dispose(){...} 
 }
 ...
 var builder = new ContainerBuilder();
 builder.RegisterType<MyType>().SingleInstance();
 var cont = builder.Build();
 app.UseHangfire(config =>
        {
            var options = new SqlServerStorageOptions();
            config.UseAutofacActivator(cont);
            config.UseSqlServerStorage("MyServer", options);
            config.UseServer();
        });

...
var c = cont.Resolve<MyType>();
c.Start();

私が見ているのは、Autofacが要求どおりに繰り返しジョブを実行しますが、MyTypeのインスタンスを破棄することです。これは、シングルトンとして定義されているため、後続の呼び出しで明らかに失敗を引き起こし、シャットダウン時にAutofacによって破棄される必要があります。

何か不足していますか、それともバグですか?

コールスタックは次のとおりです。

MyDll.dll!MyType.Dispose() 行 316 C# Hangfire.Core.dll!Hangfire.Common.Job.Dispose(オブジェクト インスタンス) 不明 Hangfire.Core.dll!Hangfire.Common.Job.Perform(Hangfire.JobActivator アクティベーター、Hangfire .IJobCancellationToken cancelToken) 不明 Hangfire.Core.dll!Hangfire.Server.JobPerformanceProcess.PerformJobWithFilters.AnonymousMethod__6() 不明 Hangfire.Core.dll!Hangfire.Server.JobPerformanceProcess.InvokePerformFilter(Hangfire.Server.IServerFilter フィルター、Hangfire.Server.PerformingContext preContext 、System.Func の続き) 不明 Hangfire.Core.dll!Hangfire.Server.JobPerformanceProcess.PerformJobWithFilters.AnonymousMethod__8() 不明 Hangfire.Core.dll!Hangfire.Server.JobPerformanceProcess.InvokePerformFilter(Hangfire.Server.IServerFilter フィルター、Hangfire.Server. PerformingContext preContext、System.Func 継続) 不明 Hangfire.Core.dll!Hangfire.Server.JobPerformanceProcess.PerformJobWithFilters.AnonymousMethod__8() 不明 Hangfire.Core.dll!Hangfire.Server.JobPerformanceProcess.PerformJobWithFilters(Hangfire.Server.PerformContext context, Hangfire.Server.IJobPerformer実行者、System.Collections.Generic.IEnumerable フィルター) 不明な Hangfire.Core.dll!Hangfire.Server.JobPerformanceProcess.Run(Hangfire.Server.PerformContext コンテキスト、Hangfire.Server.IJobPerformer 実行者) 不明な Hangfire.Core.dll!Hangfire.Server .Worker.ProcessJob(文字列 jobId、Hangfire.Storage.IStorageConnection 接続、Hangfire.Server.IJobPerformanceProcess プロセス、System.Threading.CancellationToken shutdownToken) 不明な Hangfire.Core.dll!Hangfire.Server.Worker.Execute(System.Threading.CancellationToken cancelToken) 不明 Hangfire.Core.dll!Hangfire.Server.AutomaticRetryServerComponentWrapper.ExecuteWithAutomaticRetry(System.Threading.CancellationToken cancelToken) 不明 Hangfire.Core.dll!Hangfire.Server.AutomaticRetryServerComponentWrapper.Execute(System.Threading.CancellationToken cancelToken) 不明 Hangfire。 Core.dll!Hangfire.Server.ServerSupervisor.ExecuteComponent() 不明な Hangfire.Core.dll!Hangfire.Server.ServerSupervisor.RunComponent() 不明な mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(オブジェクトの状態) 不明な mscorlib.dll! System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext、System.Threading.ContextCallback コールバック、オブジェクト状態、bool preserveSyncCtx) 不明な mscorlib.dll!システム。Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext、System.Threading.ContextCallback コールバック、オブジェクト状態、bool preserveSyncCtx) 不明な mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext、System.Threading. ContextCallback コールバック、オブジェクトの状態) 不明な mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() 不明 [Managed Transition にネイティブ]ThreadStart() 不明 [マネージド トランジションにネイティブ]ThreadStart() 不明 [マネージド トランジションにネイティブ]

4

1 に答える 1

0

これは、hangfire の最新 (ベータ) リリースで修正されています。詳細については、 https://github.com/HangfireIO/Hangfire/issues/329を参照してください。

于 2015-08-29T18:14:31.693 に答える