📜  winforms C#代码跨线程操作无效 - C#代码示例

📅  最后修改于: 2022-03-11 14:48:54.045000             🧑  作者: Mango

代码示例1
UserContrl1_LOadDataMethod()
{
    string name = "";
    if(textbox1.InvokeRequired)
    {
        textbox1.Invoke(new MethodInvoker(delegate {
          name = textbox1.text; 
        }));
    }
    if(name == "MyName")
    {
        // do whatever
    }
}