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  }

 

posted @ 2019-01-17 09:46  老马仔  阅读(456)  评论(0编辑  收藏  举报