Esempio n. 1
0
 private void HandleJobStateChanged(object sender, JobStateEventArgs e)
 {
     System.Management.Automation.Job job = sender as System.Management.Automation.Job;
     this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "BEGIN wait for write existing data", null);
     if (e.JobStateInfo.State != JobState.Running)
     {
         this._writeExistingData.WaitOne();
     }
     this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "END wait for write existing data", null);
     lock (this._syncObject)
     {
         if (!this._jobsBeingAggregated.Contains(job))
         {
             this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "Returning because job is not in _jobsBeingAggregated", null);
             return;
         }
     }
     if (e.JobStateInfo.State == JobState.Blocked)
     {
         DoUnblockJob(job);
     }
     if (((this.Force == 0) && job.IsPersistentState(e.JobStateInfo.State)) || ((this.Force != 0) && job.IsFinishedState(e.JobStateInfo.State)))
     {
         this.WriteReasonError(job);
         this.WriteJobStateInformationIfRequired(job, e);
         this.StopAggregateResultsFromJob(job);
     }
     else
     {
         this._tracer.WriteMessage("ReceiveJobCommand", "HandleJobStateChanged", Guid.Empty, job, "Returning because job state does not meet wait requirements (continue aggregating)", new string[0]);
     }
 }
Esempio n. 2
0
 private void HandleSuspendJobCompleted(object sender, AsyncCompletedEventArgs eventArgs)
 {
     System.Management.Automation.Job job = sender as System.Management.Automation.Job;
     if ((eventArgs.Error != null) && (eventArgs.Error is InvalidJobStateException))
     {
         this._warnInvalidState = true;
     }
     this.ProcessExecutionErrorsAndReleaseWaitHandle(job);
 }
Esempio n. 3
0
        private void ProcessExecutionErrorsAndReleaseWaitHandle(System.Management.Automation.Job job)
        {
            bool flag = false;

            lock (this._syncObject)
            {
                if (this._pendingJobs.Contains(job.InstanceId))
                {
                    this._pendingJobs.Remove(job.InstanceId);
                }
                else
                {
                    return;
                }
                if (this._needToCheckForWaitingJobs && (this._pendingJobs.Count == 0))
                {
                    flag = true;
                }
            }
            if (!this._wait)
            {
                job.StateChanged -= new EventHandler <JobStateEventArgs>(this.noWait_Job2_StateChanged);
                Job2 job2 = job as Job2;
                if (job2 != null)
                {
                    job2.SuspendJobCompleted -= new EventHandler <AsyncCompletedEventArgs>(this.HandleSuspendJobCompleted);
                }
            }
            ContainerParentJob job3 = job as ContainerParentJob;

            if ((job3 != null) && (job3.ExecutionError.Count > 0))
            {
                foreach (ErrorRecord record in from e in job3.ExecutionError
                         where e.FullyQualifiedErrorId == "ContainerParentJobSuspendAsyncError"
                         select e)
                {
                    if (record.Exception is InvalidJobStateException)
                    {
                        this._warnInvalidState = true;
                    }
                    else
                    {
                        this._errorsToWrite.Add(record);
                    }
                }
            }
            if (flag)
            {
                this._waitForJobs.Set();
            }
        }
Esempio n. 4
0
 private static void DoUnblockJob(System.Management.Automation.Job job)
 {
     if (job.ChildJobs.Count == 0)
     {
         PSRemotingChildJob job2 = job as PSRemotingChildJob;
         if (job2 != null)
         {
             job2.UnblockJob();
         }
         else
         {
             job.SetJobState(JobState.Running, null);
         }
     }
 }
Esempio n. 5
0
        private void noWait_Job2_StateChanged(object sender, JobStateEventArgs e)
        {
            System.Management.Automation.Job job = sender as System.Management.Automation.Job;
            switch (e.JobStateInfo.State)
            {
            case JobState.Completed:
            case JobState.Failed:
            case JobState.Stopped:
            case JobState.Suspended:
            case JobState.Suspending:
                this.ProcessExecutionErrorsAndReleaseWaitHandle(job);
                break;

            case JobState.Blocked:
            case JobState.Disconnected:
                break;

            default:
                return;
            }
        }
Esempio n. 6
0
        private void HandleStopJobCompleted(object sender, AsyncCompletedEventArgs eventArgs)
        {
            System.Management.Automation.Job targetObject = sender as System.Management.Automation.Job;
            if (eventArgs.Error != null)
            {
                this._errorsToWrite.Add(new ErrorRecord(eventArgs.Error, "StopJobError", ErrorCategory.ReadError, targetObject));
            }
            ContainerParentJob job2 = targetObject as ContainerParentJob;

            if ((job2 != null) && (job2.ExecutionError.Count > 0))
            {
                foreach (ErrorRecord record in from e in job2.ExecutionError
                         where e.FullyQualifiedErrorId == "ContainerParentJobStopAsyncError"
                         select e)
                {
                    this._errorsToWrite.Add(record);
                }
            }
            bool flag = false;

            lock (this._syncObject)
            {
                if (this._pendingJobs.Contains(targetObject.InstanceId))
                {
                    this._pendingJobs.Remove(targetObject.InstanceId);
                }
                if (this._needToCheckForWaitingJobs && (this._pendingJobs.Count == 0))
                {
                    flag = true;
                }
            }
            if (flag)
            {
                this._waitForJobs.Set();
            }
        }