示例#1
0
        public void Start()
        {
            try
            {
                if (_socket == null)
                {
                    _socket = new ClientCl(_address, _port);
                    _socket.MessageReceived += _socket_MessageReceived;
                }
            }
            catch { }
            Thread tr = new Thread(ThreadConnectChecker);

            tr.Name = "TCPCHECKER";
            tr.Start();
        }
示例#2
0
 private void ThreadConnectChecker()
 {
     while (true)
     {
         try
         {
             if (_socket == null)
             {
                 _socket = new ClientCl(_address, _port);
                 _socket.MessageReceived += _socket_MessageReceived;
             }
             if (_socket.IsConnected == false)
             {
                 _isLogined = false;
                 if (_socket != null)
                 {
                     _socket.MessageReceived -= _socket_MessageReceived;
                 }
                 _socket = new ClientCl(_address, _port);
                 _socket.MessageReceived += _socket_MessageReceived;
                 if (_loginRow != "")
                 {
                     SendLogin(_loginRow);
                 }
             }
             else if (_isLogined)
             {
                 if (sendQuery.Count() > 0)
                 {
                     for (int i = sendQuery.Count() - 1; i > -1; i--)
                     {
                         SendData(sendQuery[i]);
                         sendQuery.RemoveAt(i);
                         Thread.Sleep(100);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Debug.WriteLine(ex.Message);
         }
         Thread.Sleep(1000);
     }
 }