Beispiel #1
0
        void mySocketReceive(object obj)
        {
            Socket_wrapper sw1 = obj as Socket_wrapper;

            byte[] buffer1 = new byte[1024 * 1024];
            string s       = sw1.socket_receive(buffer1);
            //txtInfo.AppendText(s);
            dShowMsg d1 = new dShowMsg(showMsg);

            if (txtInfo.InvokeRequired)
            {
                txtInfo.Invoke(d1, s);
            }
            else
            {
                txtInfo.AppendText(s);
            }
        }
Beispiel #2
0
        void ReceiveMsg()
        {
            while (true)
            {
                dShowMsg d1 = new dShowMsg(showMsg);
                try
                {
                    byte[] buffer = new byte[1024];


                    int    n = client.Receive(buffer);
                    string s = Encoding.UTF8.GetString(buffer, 0, n);

                    this.Invoke(d1, (object)s);
                }
                catch (Exception ex)
                {
                    this.Invoke(d1, (object)ex.Message);
                    Thread.CurrentThread.Abort();
                }
            }
        }