private void CloseSessionAndClearResources()
        {
            BaseClientTransportManager.tracer.WriteLine("Clearing session with session context: {0} Operation Context: {1}", (object)this.sessionContextID, (object)this.wsManShellOperationHandle);
            IntPtr manSessionHandle = this.wsManSessionHandle;

            this.wsManSessionHandle = IntPtr.Zero;
            object obj;

            ThreadPool.QueueUserWorkItem((WaitCallback)(state =>
            {
                obj = state;
                if (!(IntPtr.Zero != (IntPtr)obj))
                {
                    return;
                }
                WSManNativeApi.WSManCloseSession((IntPtr)obj, 0);
            }), (object)manSessionHandle);
            WSManClientSessionTransportManager.RemoveSessionTransportManager(this.sessionContextID);
            if (this.closeSessionCompleted == null)
            {
                return;
            }
            this.closeSessionCompleted.Dispose();
            this.closeSessionCompleted = (WSManNativeApi.WSManShellAsync)null;
        }