internal void ExecuteWithCoreState(Action action) { RegisterEvents(); try { if (client != null) { client.DefaultCancellationToken = TokenSource.Token; } using (ProgressManager = new ProgressManager(this)) { try { action(); } catch (Exception ex) { if (!(PipeToSelectObject() && ex is PipelineStoppedException)) { ProgressManager.TryCompleteProgress(); } ProgressManager.CompleteUncompleted(true); throw; } } } catch (Exception) { UnregisterEvents(false); throw; } finally { if (client != null) { client.DefaultCancellationToken = CancellationToken.None; } if (Stopping) { UnregisterEvents(false); } } //If we're the last cmdlet in the pipeline, we need to unregister ourselves so that the upstream cmdlet //regains the ability to invoke its events when its control is returned to it if (!noClient && !Stopping && EventManager.LogVerboseEventStack.Peek().Target == this) { UnregisterEvents(true); } }
internal void EndProcessing(bool endExtended = true) { if (endExtended) { EndProcessingEx(); } ProgressManager?.CompleteUncompleted(); UnregisterEvents(false); }
/// <summary> /// Performs one-time, post-processing functionality for the cmdlet. This function is only run when the cmdlet successfully runs to completion. /// </summary> protected override void EndProcessing() { ProgressManager?.CompleteUncompleted(); UnregisterEvents(false); }