/// <summary> /// Clears the current invoke-command reference stored within /// this remote runspace /// </summary> internal void ClearInvokeCommand() { _currentLocalPipelineId = 0; _currentInvokeCommand = null; }
/// <summary> /// Keeps track of the current invoke command executing /// within the current local pipeline /// </summary> /// <param name="invokeCommand">reference to invoke command /// which is currently being processed</param> /// <param name="localPipelineId">the local pipeline id</param> internal void SetCurrentInvokeCommand(InvokeCommandCommand invokeCommand, long localPipelineId) { Dbg.Assert(invokeCommand != null, "InvokeCommand instance cannot be null, use ClearInvokeCommand() method to reset current command"); Dbg.Assert(localPipelineId != 0, "Local pipeline id needs to be supplied - cannot be 0"); _currentInvokeCommand = invokeCommand; _currentLocalPipelineId = localPipelineId; }
/// <summary> /// Determines if another Invoke-Command is executing /// in this runspace in the currently running local pipeline /// ahead on the specified invoke-command /// </summary> /// <param name="invokeCommand">current invoke-command /// instance</param> /// <param name="localPipelineId">local pipeline id</param> /// <returns>true, if another invoke-command is running /// before, false otherwise</returns> internal bool IsAnotherInvokeCommandExecuting(InvokeCommandCommand invokeCommand, long localPipelineId) { // the invoke-command's pipeline should be the currently // running pipeline. This will ensure that, we do not // return true, when one invoke-command is running as a // job and another invoke-command is entered at the // console prompt if (_currentLocalPipelineId != localPipelineId && _currentLocalPipelineId != 0) { return false; } else { // the local pipeline ids are the same // this invoke command is running may be // running in the same pipeline as another // invoke command if (_currentInvokeCommand == null) { // this is the first invoke-command, just // set the reference SetCurrentInvokeCommand(invokeCommand, localPipelineId); return false; } else if (_currentInvokeCommand.Equals(invokeCommand)) { // the currently active invoke command is the one // specified return false; } else { // the local pipeline id is the same and there // is another invoke command that is active already return true; } } }
internal void SetCurrentInvokeCommand(InvokeCommandCommand invokeCommand, long localPipelineId) { this.currentInvokeCommand = invokeCommand; this.currentLocalPipelineId = localPipelineId; }
internal bool IsAnotherInvokeCommandExecuting(InvokeCommandCommand invokeCommand, long localPipelineId) { if ((this.currentLocalPipelineId != localPipelineId) && (this.currentLocalPipelineId != 0L)) { return false; } if (this.currentInvokeCommand == null) { this.SetCurrentInvokeCommand(invokeCommand, localPipelineId); return false; } if (this.currentInvokeCommand.Equals(invokeCommand)) { return false; } return true; }
internal void ClearInvokeCommand() { this.currentLocalPipelineId = 0L; this.currentInvokeCommand = null; }