Quartz.net keeping a single Scheduler running asp.net

寵の児 提交于 2019-12-11 15:08:12

问题


Am I understanding this correctly?

ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
    sched.Start();

Is the StdSchedulerFactory a singleton?

What I want to achieve is in my global,asax on Application_Start to start up the quartz scheduler, and then later on in one of my classes create the job, the trigger, get a handle again to the scheduler, and schedule the job/trigger

But as it turns out, I need to re-start the scheduler, I thought it was already started?

Or is there now more than 1 scheduler running?


回答1:


The typical scenarios when embedding the scheduler in ASP.Net are to:

  1. Create your scheduler as a singleton and then access it using something like Scheduler.Instance.
  2. If you use DI, have the container give you a reference to the (singleton and already started) scheduler.
  3. Use a global variable and have it reference the started scheduler.


来源:https://stackoverflow.com/questions/10123623/quartz-net-keeping-a-single-scheduler-running-asp-net

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