static void job_OnTaskState(object sender, TaskStateEventArg e) { if (e.NewState == TaskState.Running) { running.Set(); } }
/// <summary> /// Handler triggered when the task state changed /// </summary> private void SchedulerJob_OnTaskState(object sender, TaskStateEventArg e) { if (this.context != null) { TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[JobMonitorEntry] Task {0}.{1} state changed: {2} -> {3}", e.TaskId.JobTaskId, e.TaskId.InstanceId, e.PreviousState, e.NewState); ThreadPool.QueueUserWorkItem(this.CallbackToQueryTaskInfo, false); } }
void ParentJob_OnTaskState(object sender, TaskStateEventArg e) { if (e.TaskId.JobTaskId == this.TaskID) { this.State = e.NewState; CancelCommand.RaiseCanExecuteChanged(); RequeueCommand.RaiseCanExecuteChanged(); } }
private static void OnTaskStateCallback(object sender, TaskStateEventArg args) { if (TaskState.Finished == args.NewState || TaskState.Failed == args.NewState || TaskState.Canceled == args.NewState) { try { IScheduler scheduler = (IScheduler)sender; ISchedulerJob job = scheduler.OpenJob(args.JobId); ISchedulerTask task = job.OpenTask(args.TaskId); } catch (Exception) { } } }
public void taskStateCallback(object src, TaskStateEventArg tsea) { ConsoleColor c = ConsoleColor.White; switch (tsea.NewState) { case TaskState.Finished: c = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Task {0} is finished", tsea.TaskId); Console.ForegroundColor = c; break; case TaskState.Running: Console.WriteLine("Task {0} is running", tsea.TaskId); break; case TaskState.Canceled: Console.WriteLine("Task {0} has been cancelled", tsea.TaskId); break; case TaskState.Dispatching: Console.WriteLine("Task {0} has been dispatched", tsea.TaskId); break; case TaskState.Failed: c = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Task {0} has failed", tsea.TaskId); Console.ForegroundColor = c; break; default: break; } }
private static void TaskStateCallback(object sender, TaskStateEventArg e) { }
void _job_OnTaskState(object sender, TaskStateEventArg e) { RefreshJobStatus(); }