Example #1
0
        public void L2Start()
        {
            try
            {
                L2TxThread      = new Thread(new ThreadStart(TxThreadProcess));
                L2TxThread.Name = "L2 - TX Thread" + cfg.GetName();

                L1Handler.Open();

                AddPkg2TxQueue.Reset();
                TxQueue.Clear();
                ThMan.AddThread(L2TxThread.Name, L2TxThread);
                L2TxThread.Start();
            }
            catch (System.Exception ex)
            {
                if (L1Handler.IsConnected())
                {
                    L1Handler.Close();
                }
                Thread t = ThMan.RemoveThread(L2TxThread.Name);

                if (t != null)
                {
                    t.Abort();
                    t = null;
                }

                throw ex;
            }
        }
        public void Close()
        {
            try
            {
                ThreadCom.Abort();
                ThMan.RemoveThread(ThreadCom.Name);
                ThreadCom = null;

	            this.clientSocket.Shutdown(SocketShutdown.Both);
	            this.clientSocket.Close();
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        /// <summary>
        /// close connection and release resources
        /// </summary>
        public virtual void Close()
        {
            try
            {
                ThreadCom.Abort();
                ThMan.RemoveThread(ThreadCom.Name);
                ThreadCom = null;

                isConnected = false;
                seialPort.DiscardOutBuffer();
                seialPort.Close();
                seialPort = null;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }