/// <summary> /// End for obtaining a runspace for the specified connection info /// </summary> /// <param name="asyncResult">async result to end on</param> /// <returns>remote runspace to invoke commands on</returns> public override Runspace EndGetRunspace(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } LocalRunspaceAsyncResult result = asyncResult as LocalRunspaceAsyncResult; if (result == null) { throw new ArgumentException(Resources.InvalidAsyncResultSpecified, "asyncResult"); } // this will throw an exeption when a runspace is not successfully // available result.EndInvoke(); Debug.Assert(result.Runspace != null, "EndInvoke() should throw an exception if runspace is null"); _tracer.WriteMessage("LocalRunspaceProvider: Request serviced and runspace returned"); Runspace runspace = result.Runspace; Debug.Assert(runspace.RunspaceStateInfo.State == RunspaceState.Opened, "Only opened runspace should be returned"); return(runspace); }
public override Runspace EndGetRunspace(IAsyncResult asyncResult) { if (asyncResult != null) { LocalRunspaceAsyncResult localRunspaceAsyncResult = asyncResult as LocalRunspaceAsyncResult; if (localRunspaceAsyncResult != null) { localRunspaceAsyncResult.EndInvoke(); this._tracer.WriteMessage("LocalRunspaceProvider: Request serviced and runspace returned"); Runspace runspace = localRunspaceAsyncResult.Runspace; return(runspace); } else { throw new ArgumentException(Resources.InvalidAsyncResultSpecified, "asyncResult"); } } else { throw new ArgumentNullException("asyncResult"); } }