internal override void ConnectAsync() { base.ReceivedDataCollection.PrepareForStreamConnect(); base.serializedPipeline.Read(); this.cmdContextId = GetNextCmdTMHandleId(); AddCmdTransportManager(this.cmdContextId, this); this.connectCmdCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(this.cmdContextId), cmdConnectCallback); this.reconnectCmdCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(this.cmdContextId), cmdReconnectCallback); lock (base.syncObject) { if (base.isClosed) { return; } WSManNativeApi.WSManConnectShellCommandEx(this.wsManShellOperationHandle, 0, base.PowershellInstanceId.ToString().ToUpper(CultureInfo.InvariantCulture), IntPtr.Zero, IntPtr.Zero, (IntPtr)this.connectCmdCompleted, ref this.wsManCmdOperationHandle); } if (this.wsManCmdOperationHandle == IntPtr.Zero) { PSRemotingTransportException e = new PSRemotingTransportException(RemotingErrorIdStrings.RunShellCommandExFailed); TransportErrorOccuredEventArgs eventArgs = new TransportErrorOccuredEventArgs(e, TransportMethodEnum.ConnectShellCommandEx); this.ProcessWSManTransportError(eventArgs); } }