Quartz.NET scheduler doesn't fire jobs/triggers once deployed

前端 未结 4 566
感情败类
感情败类 2020-12-01 11:50

INTRODUCTION

I\'m using Quartz.Net on an ASP.Net framework 4, webforms web site. Basically, the user should have the hability to fire manually a

4条回答
  •  生来不讨喜
    2020-12-01 12:22

    One thing that I have noticed is the use of the Scheduler in your asp.net application.
    You should use singleton objects.

    in your process.aspx.cs this line

    IScheduler scheduler = new StdSchedulerFactory().GetScheduler();
    

    creates a new scheduler but you should use the one you've created as static in Application_Start.

    If you want to get access to the singleton instance use a public memeber in your Global.asax.cs:

     public static ISchedulerFactory SchedulerFactory;
     public static IScheduler Scheduler;
    

    and you can reference it in your process.aspx.cs:

    MvcApplication.Scheduler.ScheduleJob(job, triggersSet, true);
    

    Another solution is to use dependency injection. You can find some info here using StructureMap and here for Unity.

    UPDATE:

    You can download a sample application (asp.net 4.0) called AspNet_Quartz here and see how it works here.

提交回复
热议问题