经过更多搜索后,我在 SO 上发现了这个问题,它讨论了在文件中实现 Quartz.NET global.asax
。
为了实现它,我只是引用了Quartz.dll
新的(在本文发布时)下载包中的,并使用了以下代码......
protected void Application_Start()
{
/*
* Include other Application_Start() code...
*/
//Job Scheduling
try {
//Setup the new Scheduler
var sf = new StdSchedulerFactory();
var sched = sf.GetScheduler();
sched.Start();
//Setup the Job
var jobDetail = new JobDetailImpl( "myJob", null, typeof( DocCleanup ) );
//Create 1 week trigger that will go on forever
var trigger = new SimpleTriggerImpl( "jobTrigger", SimpleTriggerImpl.RepeatIndefinitely, new TimeSpan( 168, 0, 0 ) );
trigger.StartTimeUtc = DateTimeOffset.Now;
//Add the job to the scheduler
sched.ScheduleJob( jobDetail, trigger );
} catch (Exception ex) { //Implement Exception code... }
}
我不想为这种特殊需要创建控制台应用程序/sql 作业/等。这主要是由于我的问题中提到的可以接受的极端不可靠性。话虽如此,如果您需要任何关于何时运行作业的保证,我怀疑您是否希望以这种方式实现 Quartz.NET。