// Helper function to raise IJobServer.JobEvent private void NotifyClients(JobEventArgs args) { // // Manually invoke each event handler to // catch disconnected clients. System.Delegate[] invkList = JobEvent.GetInvocationList(); IEnumerator ie = invkList.GetEnumerator(); while (ie.MoveNext()) { JobEventHandler handler = (JobEventHandler)ie.Current; try { //handler.Invoke(this, args); //help to debug handler.BeginInvoke(this, args, null, null); } catch (System.Exception e) { JobEvent -= handler; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message); Console.ResetColor(); } } }
private static void OnJobUnscheduled(IJob job) { JobEventHandler handler = JobUnscheduled; if (handler != null) { handler(job); } }
private static void OnJobStarted(IJob job) { JobEventHandler handler = JobStarted; if (handler != null) { handler(job); } }