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"); })); }