C#跨线程调用:不同的窗体之间调用同一个控件

 1 public void ShowMsg(string s)//接收变量,显示text公共代码 
 2 {
 3    if (this.txt_LogDisplay.InvokeRequired)
 4     {
 5          this.txt_LogDisplay.Invoke(new Action<string>((s1) => {this.txt_LogDisplay.AppendText(DateTime.Now.ToString() + s + "\r\n"); }), s);//Lamda表达式
 9    }
10   else
11    {
12          this.txt_LogDisplay.AppendText(DateTime.Now.ToString() +s + "\r\n");
13    }
14  }

猜你喜欢

转载自www.cnblogs.com/MaZai/p/10280616.html