示例#1
0
        private void LoopConnect()
        {
            int attempts = 0;

            while (!_clientSocket.Connected)
            {
                try
                {
                    attempts++;
                    _clientSocket.Connect(IPAddress.Loopback, 101);
                    _usersSocket.Connect(IPAddress.Loopback, 102);
                }
                catch (SocketException)
                {
                    txtMsgBox.AppendText("Connection attepts: " + attempts.ToString() + "\n");
                }
            }

            txtMsgBox.AppendText("Connected" + "\n");
            SendUsr();

            ReceiveMsgs.RunWorkerAsync();

            btnSend.Enabled = true;
            Application.DoEvents();
        }
示例#2
0
 private void NewReceiveHandler(string content)
 {
     _logger.Info("接收到信息:{0}", content);
     DispatcherHelper.UIDispatcher.Invoke(() =>
     {
         ReceiveMsgs.Add(content);
     });
 }