/// <summary>
        /// Called from context cleanup thread (on the server) or when Disconnecting (on the client).
        /// </summary>
        public void Close()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;
            UserContext.OnDisconnect(); // sets Connected=false

            // close client connection
            if (Connection != null)
            {
                try
                {
                    Connection.Close();
                }
                catch (Exception)
                {
                    // skip
                }
                Connection = null;
            }
            SendReady.Release();
            ReceiveReady.Release();
            //Cancellation.Dispose();
            //ReceiveReady.Dispose();
            //SendReady.Dispose(); delay disposing until GC does it. Send thread will use the semaphore.
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            Connected = false;
            UserContext.OnDisconnect();

            // close client connection
            if (Connection != null)
            {
                try
                {
                    Connection.Close();
                }
                catch (Exception)
                {
                    // skip
                }
            }
            SendReady.Release();
            ReceiveReady.Release();
        }
Exemple #3
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     Connected = false;
     UserContext.OnDisconnect();
 }
Exemple #4
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            try
            {
                Connected = false;
                UserContext.OnDisconnect();

                // close client connection
                if (Connection != null)
                {
                    try
                    {
                        Connection.Close();
                    }
                    catch (Exception)
                    {
                        // skip
                    }
                }
            }
            catch
            {}

            try
            {
                SendReady.Release();
                ReceiveReady.Release();
            }
            catch
            {}

            try
            {
                if (SendReady != null)
                {
                    SendReady.Dispose();
                }

                if (ReceiveReady != null)
                {
                    ReceiveReady.Dispose();
                }
            }
            catch
            {}

            try
            {
                if (ReceiveEventArgs != null)
                {
                    ReceiveEventArgs.Dispose();
                }
            }
            catch
            {}

            try
            {
                if (SendEventArgs != null)
                {
                    SendEventArgs.Dispose();
                }
            }
            catch
            {}
        }