我有一个 Web 应用程序,我想实现调度程序我正在使用 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();
}
}
我想知道如果我让调度程序运行而不停止它是否有任何问题