我有一个服务:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class PremieraInteraction : ServiceInit, IPremieraInteraction
{
public PremieraInteraction()
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// construct job info
IJobDetail jobDetail = JobBuilder.Create<PremieraUpdate>().WithIdentity("PremieraUpdateJob").Build();
ITrigger trigger =
TriggerBuilder.Create().WithIdentity("PremieraUpdateTrigger").StartNow().WithSimpleSchedule(
x => x.WithIntervalInSeconds(10)).Build();
sched.ScheduleJob(jobDetail, trigger);
}
}
这是工作:
public class PremieraUpdate:IJob
{
public void Execute(IJobExecutionContext context)
{
Debug.WriteLine("Fire");
}
}
问题是它只工作一次。为什么调度程序不是每 10 秒重复一次?