public static Task RunAndDispose(Func<Task> action) { try { action(); } finally { System.Diagnostics.Trace.WriteLine("Finaly"); if (!HttpContextLifecycle.HasContext()) { new HybridLifecycle().FindCache(null).DisposeAndClear(); } } return Task.FromResult(0); }
public override async Task RunAsync() { await SemaphoreSlim.WaitAsync(); try { if (this.IsShuttingDown || this.Pause) return; await IoCWrapper.RunAndDispose(async () => { var draftsService = IoCWrapper.GetInstance<IBlogPostDraftsService>(); await draftsService.RunConvertDraftsToPostsJobAsync(); }); } finally { SemaphoreSlim.Release(); } }
ActivatedEventTimeDurationThread Activated Historical Code ContextException thrown: 'System.ObjectDisposedException' in mscorlib.dll ("The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.") Exception thrown: 'System.ObjectDisposedException' in mscorlib.dll ("The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.") Hyperlink: Activate Historical Debugging346.49s[14880] Worker Thread
به نظرتون جایی از کد رو اشتباه نوشتم؟