Hangfire.Ninject icon indicating copy to clipboard operation
Hangfire.Ninject copied to clipboard

Better handling of deterministic disposal feature

Open odinserj opened this issue 9 years ago • 0 comments

Currently the following method is used to dispose all the requested services, when background job is completed. This method gracefully handles transient dependencies, but it also disposes singleton services that implement the IDisposable interface.

public override void DisposeScope()
{
    _kernel.Components.Get<ICache>().Clear(JobActivatorScope.Current);
}

It's worth to read this article to know how to correctly implement deterministic disposal with Ninject: http://mono.software/2016/04/21/Ninject-ambient-scope-and-deterministic-dispose/

odinserj avatar Jul 13 '16 08:07 odinserj