Correct disposing of jobClient at Service Layer

Hi @odinserj

I have read this howto - How to kick off static `BackgroundJob` methods and write unit tests

But I am using HangFire to enqueue job at service layer rather than MVC controller level and I am writing Unit Tests for the Service. So my MVC controller will call a service layer method. So I have an Interface with two methods on it. Then in my implementation of interface I am using DI so I have something like the following:

    private readonly IBackgroundJobClient _jobClient;

    public MyService(IBackgroundJobClient jobClient)
    {
        _jobClient = jobClient;
    }

    public void MyMethod(string passedId)
    {
       //SetUp stuff

        _jobClient.Enqueue(() => _LongRunningTaskMethod(passedId)
    } 

What I am wondering is in what way if any should I be handling Dispose here as you mention it in the post I have linked to above. Should that be another method on my interface?

Register the IBackgroundJobClient interface inside a request scope, and your container will call its Dispose method automatically after processing the request. There are two GitHub issues to simplify this case by removing the IDisposable interface from HangFire Client classes:

This issue is obsolete since HangFire 0.9.