Quartz.Net嵌入Asp.NET MVC2,没有发射过工作 [英] Quartz.Net embedded into Asp.NET MVC2, not firing off jobs
问题描述
我试图让Quartz.net嵌入到我的.Net应用程序MVC2工作。我知道这是不理想,但我只是想获得它,并把它移到一个服务之前运行。我不能让我的工作,以火过,但我想我正确配置。在我的Global.asax.cs:
I'm trying to get Quartz.net working by embedding into my .Net MVC2 application. I know this is not ideal, but I'm just trying to get it up and running before moving it over to a service. I can't get my jobs to fire off, but I think I'm configured correctly. In my Global.asax.cs:
protected void Application_Start()
{
Quartz.IScheduler scheduler = BuildQuartzScheduler();
...
}
和方法,从教程直取:
private IScheduler BuildQuartzScheduler()
{
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// construct job info
JobDetail jobDetail = new JobDetail("myJob", null, typeof(QuartzController));
// fire every hour
Trigger trigger = TriggerUtils.MakeMinutelyTrigger();
// start on the next even hour
trigger.StartTimeUtc = TriggerUtils.GetEvenMinuteDate(DateTime.UtcNow);
trigger.Name = "myTrigger";
sched.ScheduleJob(jobDetail, trigger);
return sched;
}
和控制器:
public class QuartzController : IJob
{
public QuartzController() {
}
public void Execute(JobExecutionContext context) {
throw new NotImplementedException();
}
}
没什么东西开枪。这是怎么回事?我敢肯定,必须有一个简单的语法错误,但它快把我逼疯了!
Nothing ever gets fired. What's going on? I'm sure there must be a simple syntax mistake, but it is driving me crazy!
推荐答案
如果的Application_Start
看起来像这一点,那么我认为你的调度
变量很可能会尽快垃圾收集作为方法执行完毕。
If Application_Start
looks like that, then I reckon your scheduler
variable is likely to be garbage collected as soon as that method finishes executing.
我在调度
引用存储为你的的HttpApplication
类的静态变量。这种方式,参考挂绕的过程的持续时间。一种猜测,但值得一试。
I'd store a reference to the scheduler
as a static variable in your HttpApplication
class. This way, the reference hangs around for the duration of the process. A guess, but worth a shot.
这篇关于Quartz.Net嵌入Asp.NET MVC2,没有发射过工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!