internal override void DisconnectAsync()
        {
            Dbg.Assert(!isClosed, "object already disposed");

            // Pass the WSManConnectionInfo object IdleTimeout value if it is
            // valid.  Otherwise pass the default value that instructs the server
            // to use its default IdleTimeout value.
            uint uIdleTimeout = (ConnectionInfo.IdleTimeout > 0) ?
                (uint)ConnectionInfo.IdleTimeout : UseServerDefaultIdleTimeoutUInt;

            // startup info 
            WSManNativeApi.WSManShellDisconnectInfo disconnectInfo = new WSManNativeApi.WSManShellDisconnectInfo(uIdleTimeout);

            //Add ETW traces

            // disconnect Callback
            _disconnectSessionCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(_sessionContextID), s_sessionDisconnectCallback);
            try
            {
                lock (syncObject)
                {
                    if (isClosed)
                    {
                        // the transport is already closed
                        // anymore.
                        return;
                    }

                    int flags = 0;
                    flags |= (ConnectionInfo.OutputBufferingMode == Runspaces.OutputBufferingMode.Block) ?
                                    (int)WSManNativeApi.WSManShellFlag.WSMAN_FLAG_SERVER_BUFFERING_MODE_BLOCK : 0;
                    flags |= (ConnectionInfo.OutputBufferingMode == Runspaces.OutputBufferingMode.Drop) ?
                                    (int)WSManNativeApi.WSManShellFlag.WSMAN_FLAG_SERVER_BUFFERING_MODE_DROP : 0;

                    WSManNativeApi.WSManDisconnectShellEx(_wsManShellOperationHandle,
                            flags,
                            disconnectInfo,
                            _disconnectSessionCompleted);
                }
            }
            finally
            {
                disconnectInfo.Dispose();
            }
        }
 internal override void DisconnectAsync()
 {
     int serverIdleTimeOut = (this._connectionInfo.IdleTimeout > 0) ? ((int) this._connectionInfo.IdleTimeout) : int.MaxValue;
     WSManNativeApi.WSManShellDisconnectInfo info = new WSManNativeApi.WSManShellDisconnectInfo(serverIdleTimeOut);
     this.disconnectSessionCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(this.sessionContextID), sessionDisconnectCallback);
     try
     {
         lock (base.syncObject)
         {
             if (!base.isClosed)
             {
                 int flags = 0;
                 flags |= (this._connectionInfo.OutputBufferingMode == OutputBufferingMode.Block) ? 8 : 0;
                 flags |= (this._connectionInfo.OutputBufferingMode == OutputBufferingMode.Drop) ? 4 : 0;
                 WSManNativeApi.WSManDisconnectShellEx(this.wsManShellOperationHandle, flags, (IntPtr) info, (IntPtr) this.disconnectSessionCompleted);
             }
         }
     }
     finally
     {
         info.Dispose();
     }
 }