posts - 432,  comments - 39,  views - 54万
< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8
    this.Invoke(new Action(() =>
                                    {
                                        this.btnReplay.Enabled = true;
                                    }));

 

复制代码
//定义
  public delegate void OnUpdateMessEventHandler(string mess);
        public event OnUpdateMessEventHandler OnUpdateMessEvent;
//事件源
 OnUpdateMessEvent("User 在主函数里面Remove相关UserList,脱离的线程ID=" + UserThread.ManagedThreadId.ToString() + ";脱离的MeterIP=" + MeterIP);

//接收
  UserClass UserClient = new UserClass(NewClient, 10086);
          
                  Thread ClientReceiveThread = new Thread(new ThreadStart(UserClient.ReciveData));
                UserClient.OnUpdateMessEvent += Cli_OnUpdateMessEvent;

    private void Cli_OnUpdateMessEvent(string mess)
        {
            UpMess(mess);
        }
        void  UpMess(string mess)
        {
            this.Invoke(new Action(() =>
            {
                this.richTextBox1.AppendText(mess + "\r\n");
            }));
        }
复制代码

 

posted on   小石头的一天  阅读(41)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示