what's the purpose of ReturnJob in IJobFactory

2019-06-15 16:08发布

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();
        }
    }

2条回答
Animai°情兽
2楼-- · 2019-06-15 16:20

You can clean up the job;

   public void ReturnJob(IJob job)
   {
       (job as IDisposable)?.Dispose();
   }
查看更多
Explosion°爆炸
3楼-- · 2019-06-15 16:22

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

Check this commit on github.

查看更多
登录 后发表回答