Ejemplo n.º 1
0
        /// <summary>
        /// Disconnects from remote application and closes channel.
        /// </summary>
        public override void Disconnect()
        {
#if UTILIZA_DESCONEXION_AUTOMATICA
            if (timerTimeout != null)
            {
                timerTimeout.Stop();
                timerTimeout = null;//????
            }
#endif

            if (CommunicationState != CommunicationStates.Connected)
            {
                return;
            }

            _running = false;
            try
            {
                if (_clientSocket.Connected)
                {
                    _clientSocket.Close();
                }

                _clientSocket.Dispose();
            }
            catch
            {
            }

            CommunicationState = CommunicationStates.Disconnected;
            OnDisconnected();
        }