0
我有一個Web應用程序,我想實現調度我使用Quartez.Net庫停止Quartez.net調度
我下面的代碼添加到應用程序中的Global.asax
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
MyScheduler.StartScheduler();
}
我創建以下類,開始我的工作,定期
public class MyScheduler
{
public void StartScheduler()
{
// First we must get a reference to a scheduler
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
// computer a time that is on the next round minute
DateTimeOffset runTime = DateBuilder.EvenMinuteDate(DateTimeOffset.UtcNow);
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<MyJob>()
.WithIdentity("job1", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.WithDailyTimeIntervalSchedule(
x => x.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(14, 41))
.EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(14,43))
.WithIntervalInSeconds(30))
.Build();
// Tell quartz to schedule the job using our trigger
sched.ScheduleJob(job, trigger);
// Start up the scheduler (nothing can actually run until the
// scheduler has been started)
sched.Start();
}
}
我想知道的是有什麼問題,如果我離開這個調度不停止運行它
感謝LeftyX對那篇有用的博客文章 – 2012-07-23 15:20:32