internal override void CloseAsync()
        {
            bool flag = false;

            lock (this.syncObject)
            {
                if (this.isClosed)
                {
                    return;
                }
                if (!this.isCreateCallbackReceived)
                {
                    this.isClosePending = true;
                    return;
                }
                this.isClosed = true;
                if (IntPtr.Zero == this.wsManShellOperationHandle)
                {
                    flag = true;
                }
            }
            base.CloseAsync();
            if (flag)
            {
                try
                {
                    this.RaiseCloseCompleted();
                }
                finally
                {
                    WSManClientSessionTransportManager.RemoveSessionTransportManager(this.sessionContextID);
                }
            }
            else
            {
                BaseTransportManager.ETWTracer.AnalyticChannel.WriteInformation(PSEventId.WSManCloseShell, PSOpcode.Disconnect, PSTask.None, (object)this.RunspacePoolInstanceId);
                this.closeSessionCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(this.sessionContextID), WSManClientSessionTransportManager.sessionCloseCallback);
                WSManNativeApi.WSManCloseShell(this.wsManShellOperationHandle, 0, (IntPtr)this.closeSessionCompleted);
            }
        }
 internal override void PrepareForRedirection()
 {
     this.closeSessionCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(this.sessionContextID), WSManClientSessionTransportManager.sessionCloseCallback);
     WSManNativeApi.WSManCloseShell(this.wsManShellOperationHandle, 0, (IntPtr)this.closeSessionCompleted);
 }