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 }