internal PSWmiChildJob(Cmdlet cmds, string computerName, ThrottleManager throttleManager, int count) : base(null, null) { this.syncObject = new object(); this.statusMessage = "test"; base.UsesResultsCollection = true; this.computerName = computerName; this.throttleManager = throttleManager; this.wmiSinkArray = new ArrayList(); ManagementOperationObserver managementOperationObserver = new ManagementOperationObserver(); this.wmiSinkArray.Add(managementOperationObserver); PSWmiChildJob pSWmiChildJob = this; pSWmiChildJob.sinkCompleted = pSWmiChildJob.sinkCompleted + count; managementOperationObserver.ObjectReady += new ObjectReadyEventHandler(this.NewObject); managementOperationObserver.Completed += new CompletedEventHandler(this.JobDone); this.helper = new WmiAsyncCmdletHelper(this, cmds, computerName, managementOperationObserver, count); this.helper.WmiOperationState += new EventHandler <WmiJobStateEventArgs>(this.HandleWMIState); this.helper.ShutdownComplete += new EventHandler <EventArgs>(this.JobDoneForWin32Shutdown); base.SetJobState(JobState.NotStarted); IThrottleOperation throttleOperation = this.helper; throttleOperation.OperationComplete += new EventHandler <OperationStateEventArgs>(this.HandleOperationComplete); throttleManager.ThrottleComplete += new EventHandler <EventArgs>(this.HandleThrottleComplete); throttleManager.AddOperation(throttleOperation); }
private void HandleOperationComplete(object sender, OperationStateEventArgs stateEventArgs) { WmiAsyncCmdletHelper wmiAsyncCmdletHelper = (WmiAsyncCmdletHelper)sender; if (wmiAsyncCmdletHelper.State != WmiState.NotStarted) { if (wmiAsyncCmdletHelper.State != WmiState.Running) { if (wmiAsyncCmdletHelper.State != WmiState.Completed) { if (wmiAsyncCmdletHelper.State != WmiState.Failed) { base.SetJobState(JobState.Stopped, wmiAsyncCmdletHelper.InternalException); return; } else { base.SetJobState(JobState.Failed, wmiAsyncCmdletHelper.InternalException); return; } } else { base.SetJobState(JobState.Completed, wmiAsyncCmdletHelper.InternalException); return; } } else { base.SetJobState(JobState.Running, wmiAsyncCmdletHelper.InternalException); return; } } else { base.SetJobState(JobState.Stopped, wmiAsyncCmdletHelper.InternalException); return; } }
internal PSWmiChildJob(Cmdlet cmds, string computerName, ThrottleManager throttleManager) : base(null, null) { this.syncObject = new object(); this.statusMessage = "test"; base.UsesResultsCollection = true; this.computerName = computerName; this.throttleManager = throttleManager; this.wmiSinkArray = new ArrayList(); ManagementOperationObserver managementOperationObserver = new ManagementOperationObserver(); this.wmiSinkArray.Add(managementOperationObserver); PSWmiChildJob pSWmiChildJob = this; pSWmiChildJob.sinkCompleted = pSWmiChildJob.sinkCompleted + 1; managementOperationObserver.ObjectReady += new ObjectReadyEventHandler(this.NewObject); managementOperationObserver.Completed += new CompletedEventHandler(this.JobDone); this.helper = new WmiAsyncCmdletHelper(this, cmds, computerName, managementOperationObserver); this.helper.WmiOperationState += new EventHandler<WmiJobStateEventArgs>(this.HandleWMIState); this.helper.ShutdownComplete += new EventHandler<EventArgs>(this.JobDoneForWin32Shutdown); base.SetJobState(JobState.NotStarted); IThrottleOperation throttleOperation = this.helper; throttleOperation.OperationComplete += new EventHandler<OperationStateEventArgs>(this.HandleOperationComplete); throttleManager.ThrottleComplete += new EventHandler<EventArgs>(this.HandleThrottleComplete); throttleManager.AddOperation(throttleOperation); }
/// <summary> /// Internal constructor for initializing WMI jobs, where WMI command is executed a variable /// number of times. /// </summary> internal PSWmiChildJob(Cmdlet cmds, string computerName, ThrottleManager throttleManager, int count) : base(null, null) { UsesResultsCollection = true; Location = computerName; _throttleManager = throttleManager; _wmiSinkArray = new ArrayList(); ManagementOperationObserver wmiSink = new ManagementOperationObserver(); _wmiSinkArray.Add(wmiSink); _sinkCompleted += count; wmiSink.ObjectReady += new ObjectReadyEventHandler(this.NewObject); wmiSink.Completed += new CompletedEventHandler(this.JobDone); _helper = new WmiAsyncCmdletHelper(this, cmds, computerName, wmiSink, count); _helper.WmiOperationState += new EventHandler<WmiJobStateEventArgs>(HandleWMIState); _helper.ShutdownComplete += new EventHandler<EventArgs>(JobDoneForWin32Shutdown); SetJobState(JobState.NotStarted); IThrottleOperation operation = _helper; operation.OperationComplete += new EventHandler<OperationStateEventArgs>(HandleOperationComplete); throttleManager.ThrottleComplete += new EventHandler<EventArgs>(HandleThrottleComplete); throttleManager.AddOperation(operation); }