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

被刻印的时光 ゝ 提交于 2020-01-03 07:37:06

问题


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

回答1:


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

Check this commit on github.




回答2:


You can clean up the job;

   public void ReturnJob(IJob job)
   {
       (job as IDisposable)?.Dispose();
   }


来源:https://stackoverflow.com/questions/20587433/whats-the-purpose-of-returnjob-in-ijobfactory-interface-for-quartz-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!