private void timer_10ms_Tick(object sender, EventArgs e)
        {
            string err = "";

            if (bConnected)
            {
                string s;
                if (client.Receive(out s, out err))
                {
                    if (s != "")
                    {
                        textBox_Receive.Text += s;
                    }
                }
                else
                {
                    // error handling, client socket seems to be disconnected
                    client.Disconnect(out err);
                    textBox_Receive.Text += err + "\r\n";
                }
                textBox_Receive.SelectionStart = textBox_Receive.TextLength;
                textBox_Receive.ScrollToCaret();
            }

            // Check every 1 second (1000 ms) if the socket is still connected
            if (nTimer_10ms % 100 == 0)
            {
                if (bConnected)
                {
                    if (!client.IsStillConnected())
                    {
                        bConnected = false;
                        SetGUIstate(bConnected);
                        textBox_Receive.Text          += "DEBUG > " + "Disconnected from server.\r\n";
                        textBox_Receive.SelectionStart = textBox_Receive.TextLength;
                        textBox_Receive.ScrollToCaret();
                    }
                }
            }
            nTimer_10ms++;
        }
Пример #2
0
        private void Timer_10ms_Tick(object sender, EventArgs e)
        {
            string err = "";

            if (bConnected)
            {
                if (client.Receive(out string s, out err))
                {
                    if (s != "")
                    {
                        tv_Info.Text += s;
                    }
                }
                else
                {
                    // error handling, client socket seems to be disconnected
                    client.Disconnect(out err);
                    tv_Info.Text += err + "\r\n";
                }
            }

            // Check every 1 second (1000 ms) if the socket is still connected
            if (nTimer_10ms % 100 == 0)
            {
                if (bConnected)
                {
                    if (!client.IsStillConnected())
                    {
                        bConnected = false;
                        SetGUIstate(bConnected);
                        tv_Info.Text += "DEBUG > " + "Disconnected from server.\r\n";
                    }
                }
            }
            nTimer_10ms++;
        }