Esempio n. 1
0
        private void JobStateChanged(object sender, JobStateEventArg e)
        {
            string newJobState = String.Format("Job state changed to {0}", GetStateDescription(e.NewState));

            OutputState(newJobState);
            SetStatus(newJobState);
        }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        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...");
            }
        }
Esempio n. 5
0
        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)
                {
                }
            }
        }
Esempio n. 6
0
        /// <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 */);
            }
        }
Esempio n. 7
0
        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;
            }
        }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
 void _job_OnJobState(object sender, JobStateEventArg e)
 {
     RefreshJobStatus();
 }