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 }
本人从事苦逼的自动化行业,作为一名机器视觉工程师,希望多与同行交流,一些开发和调试经验。
对于新入行的,尽量的帮助你们,也请你们觉得作者的博文不错,可以打赏一下,也算对于作者的支持。
希望大家一起进步。。。