SchedulerListeners are much like ITriggerListeners and IJobListeners, except they receive notification of events within the scheduler itself - not necessarily events related to a specific trigger or job.
Scheduler-related events include: the addition of a job/trigger, the removal of a job/trigger, a serious error within the scheduler, notification of the scheduler being shutdown, and others.
SchedulerListeners同TriggerListeners及JobListeners非常相似,SchedulerListeners只接收与特定trigger 或job无关的Scheduler自身事件通知。
Scheduler相关的事件包括:增加job或者trigger,移除Job或者trigger, scheduler内部发生的错误,scheduler将被关闭的通知,以及其他。
The ISchedulerListener Interface
1 public interface ISchedulerListener 2 { 3 void JobScheduled(Trigger trigger); 4 5 void JobUnscheduled(string triggerName, string triggerGroup); 6 7 void TriggerFinalized(Trigger trigger); 8 9 void TriggersPaused(string triggerName, string triggerGroup); 10 11 void TriggersResumed(string triggerName, string triggerGroup); 12 13 void JobsPaused(string jobName, string jobGroup); 14 15 void JobsResumed(string jobName, string jobGroup); 16 17 void SchedulerError(string msg, SchedulerException cause); 18 19 void SchedulerShutdown(); 20 }
SchedulerListeners are registered with the scheduler's ListenerManager. SchedulerListeners can be virtually any object that implements the ISchedulerListener interface.
Adding a SchedulerListener:
scheduler.ListenerManager.AddSchedulerListener(mySchedListener);
Removing a SchedulerListener:
scheduler.ListenerManager.RemoveSchedulerListener(mySchedListener);
除了不分“全局”或者“非全局”监听器外,SchedulerListeners创建及注册的方法同其他监听器类型十分相同。所有实现Quartz.ISchedulerListener接口的对象都是SchedulerListeners。