private void JobStateChanged(object sender, JobStateEventArg e) { string newJobState = String.Format("Job state changed to {0}", GetStateDescription(e.NewState)); OutputState(newJobState); SetStatus(newJobState); }
static void job_OnJobState(object sender, JobStateEventArg e) { //we want to check that the job is in the Running state or these finishing states. if (e.NewState == JobState.Running || e.NewState == JobState.Finished || e.NewState == JobState.Canceled || e.NewState == JobState.Failed) { Console.WriteLine("Job is " + e.NewState.ToString()); //allow the main thread to continue jobStatus.Set(); } }
private static void JobStateCallback(object sender, JobStateEventArg e) { string newState = e.NewState.ToString(); Console.WriteLine($"{e.JobId}: {newState}"); if (JobState.Canceled == e.NewState || JobState.Failed == e.NewState || JobState.Finished == e.NewState) { manualEvent.Set(); } }
static void job_OnJobState(object sender, JobStateEventArg e) { if (e.NewState == JobState.Finished) //the job is finished { task.Refresh(); // update the task object with updates from the scheduler Console.WriteLine("Job completed."); Console.WriteLine("Output: " + task.Output); //print the task's output jobFinishedEvent.Set(); } else if (e.NewState == JobState.Canceled || e.NewState == JobState.Failed) { Console.WriteLine("Job did not finish."); jobFinishedEvent.Set(); } else if (e.NewState == JobState.Queued && e.PreviousState != JobState.Validating) { Console.WriteLine("The job is currently queued."); Console.WriteLine("Waiting for job to start..."); } }
private static void OnJobStateCallback(object sender, JobStateEventArg args) { if (JobState.Canceled == args.NewState || JobState.Failed == args.NewState || JobState.Finished == args.NewState) { manualReset.Set(); } else { try { IScheduler scheduler = (IScheduler)sender; ISchedulerJob job = scheduler.OpenJob(args.JobId); //TODO: do something with the job } catch (Exception) { } } }
/// <summary> /// Handler triggered when the job state changed /// </summary> private void SchedulerJob_OnJobState(object sender, JobStateEventArg e) { JobState state = e.NewState; if (previousState != state && this.context != null) { // reset isRequeuingJob flag if job state changed into JobState.Queued if (1 == this.isRequeuingJob) { if (state == JobState.Queued) { Interlocked.Exchange(ref this.isRequeuingJob, 0); TraceHelper.TraceEvent(this.sessionid, TraceEventType.Verbose, "[JobMonitorEntry] Job requeue completed"); } } TraceHelper.TraceEvent(this.sessionid, TraceEventType.Information, "[JobMonitorEntry] Job state changed: {0} -> {1}", previousState, state); // Bug 10250: Job.State is not updated after triggered event, so need to refresh the job instance by setting the parameter to true ThreadPool.QueueUserWorkItem(this.CallbackToQueryTaskInfo, true /* ask to refresh the job instance */); } }
private void jobStateCallback(object src, JobStateEventArg jsea) { switch (jsea.NewState) { case JobState.Submitted: Console.WriteLine("Job {0} has been submitted", jsea.JobId); break; case JobState.Running: Console.WriteLine("Job {0} is now running", jsea.JobId); break; case JobState.Finished: case JobState.Failed: case JobState.Canceled: Console.WriteLine("Job {0} finished with status {1}", jsea.JobId, jsea.NewState.ToString()); manualEvent.Set( ); break; default: break; } }
private void JobStateChanged(object sender, JobStateEventArg e) { string newJobState = String.Format("Job state for job {0} changed to {1}", e.JobId, GetStateDescription(e.NewState)); OutputState(newJobState); SetStatus(newJobState); }
void _job_OnJobState(object sender, JobStateEventArg e) { RefreshJobStatus(); }