Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the purpose of ReturnJob in IJobFactory Interface for Quartz.Net

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();
        }
    }
like image 683
pedrommuller Avatar asked Dec 14 '13 19:12

pedrommuller


2 Answers

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

Check this commit on github.

like image 155
Cybermaxs Avatar answered Sep 20 '22 17:09

Cybermaxs


You can clean up the job;

   public void ReturnJob(IJob job)
   {
       (job as IDisposable)?.Dispose();
   }
like image 44
gureumi Avatar answered Sep 20 '22 17:09

gureumi