我有Windows窗体应用程序,单击该按钮后它启动了多个计划的作业-基本上启动了SyntaxError: Unexpected token < in JSON at position 0
。假设在此类中发生了什么,我想停止这项工作,甚至更好-停止整个调度程序。我该怎么办?
Quartz文档中的简单代码示例:
class HelloJob
也许可以选择将对 public partial class Form1 : Form
{
IScheduler scheduler;
public Form1()
{
InitializeComponent();
}
private void start_MouseClick(object sender, MouseEventArgs e)
{
try
{
scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
IJobDetail job = JobBuilder.Create<HelloJob>()
.StoreDurably()
.WithIdentity("job1", "group1")
.Build();
scheduler.AddJob(job, true);
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(3)
.RepeatForever())
.ForJob(job)
.Build();
ITrigger trigger2 = TriggerBuilder.Create()
.WithIdentity("trigger2", "group2")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(4)
.RepeatForever())
.ForJob(job)
.Build();
scheduler.ScheduleJob(trigger);
scheduler.ScheduleJob(trigger2);
}
catch (SchedulerException e)
{
Console.WriteLine(e);
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
if (scheduler != null)
scheduler.Shutdown();
}
}
public class HelloJob : IJob
{
public void Execute(IJobExecutionContext context)
{
Console.WriteLine("Greetings from HelloJob!");
//something goes wrong - we want to end here
}
}
}
的引用发送到IScheduler
并在此处调用方法class HelloJob
,但这对我来说很奇怪。
任何帮助将不胜感激!