Beispiel #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         WorkerThreadSynchronization.BeginSafeToCallbackRegion();
     }
     base.Dispose(disposing);
 }
Beispiel #2
0
        public override void Flush()
        {
            if (m_sendLength <= 0)
            {
                return;
            }

            m_workerThreadSynchronization.BeginSafeToCallbackRegion();
            try
            {
                m_stream.Write(m_sendBuffer, 0, m_sendLength);
                m_stream.Flush();
            }
            finally
            {
                m_workerThreadSynchronization.EndSafeToCallbackRegion();
            }
            m_sendLength = 0;
        }
        /// <summary>
        /// Disconnects the socket.  Does not throw an exception.
        /// </summary>
        /// <remarks></remarks>
        public void Disconnect()
        {
            Socket socket = Interlocked.Exchange(ref m_socket, null);

            if (socket != null)
            {
                try
                {
                    socket.Shutdown(SocketShutdown.Both);
                }
                catch
                {
                }
                try
                {
                    socket.Close();
                }
                catch
                {
                }
            }
            WorkerThreadSynchronization.BeginSafeToCallbackRegion();
        }