15

I'm using simpleInjector as IOC container bue I dont have a clear view of what's the responsabillity of ReturnJob, I'd like to know how can I proceed?

this is the code I have done so far:

public class SimpleInjectorJobFactory:IJobFactory
    {
        private readonly Container _container;
        public SimpleInjectorJobFactory()
        {
            _container= new Container();
        }

        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            return _container.GetInstance(bundle.JobDetail.JobType) as IJob;
        }

        public void ReturnJob(IJob job)
        {
            throw new System.NotImplementedException();
        }
    }
pedrommuller
  • 15,741
  • 10
  • 76
  • 126

2 Answers2

10

This method allow returning the instance back to IoC container & Job factory for proper cleanup.

Check this commit on github.

Cybermaxs
  • 24,378
  • 8
  • 83
  • 112
  • 3
    adding link to the implementation of StructureMap for Quartz.Net https://gist.github.com/Saanch/2c1e63b225ff5d13d145 – Saanch Nov 11 '14 at 06:53
3

You can clean up the job;

   public void ReturnJob(IJob job)
   {
       (job as IDisposable)?.Dispose();
   }
gureumi
  • 71
  • 4