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();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the thread to receive messages from socket.
        /// </summary>
        protected override void StartInternal()
        {
            _running = true;
            IAsyncResult res = _clientSocket.BeginReceive(_buffer, 0, _buffer.Length, 0, new AsyncCallback(ReceiveCallback), null);

#if UTILIZA_DESCONEXION_AUTOMATICA
            //  if (res.IsCompleted)
            {
                timerTimeout          = new Threading.Timer(120000);
                timerTimeout.Elapsed += new EventHandler(timerTimeout_Elapsed);
                timerTimeout.Start();
            }
#endif
        }
Ejemplo n.º 3
0
 private void button12_Click(object sender, EventArgs e)
 {
     if (null != _perRaido)
     {
         _perRaido.WaitToStop();
         _perRaido = null;
     }
     else
     {
         _perRaido          = new Hik.Threading.Timer(100);
         _perRaido.Elapsed += __PerRadio_Elapsed;
         _perRaido.Start();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Starts the thread to receive messages from socket.
        /// </summary>
        protected override void StartInternal()
        {
            _running = true;
            IAsyncResult res = _clientSocket.BeginReceive(_buffer, 0, _buffer.Length, 0, new AsyncCallback(ReceiveCallback), null);

#if UTILIZA_DESCONEXION_AUTOMATICA
            //  if (res.IsCompleted)
            {
                timerTimeout = new Threading.Timer(120000);
                timerTimeout.Elapsed += new EventHandler(timerTimeout_Elapsed);
                timerTimeout.Start();
            }
#endif
        }
Ejemplo n.º 5
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();
        }