WinForms interthread modification

前端 未结 4 1806
傲寒
傲寒 2020-12-21 13:46

Whenever I want to modify a winform from another thread, I need to use

->Invoke(delegate, params)

so that the modification occurs in the winf

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-21 14:01

    Look at using the existing System.Action and System.Func delegates:

    control.Invoke(
        new Action(
            (i, s) => MessageBox.Show(String.Format(s, i))), 1, "{0}");
    int iret = (int) control.Invoke(new Func(i1 => i1 + 1));
    

提交回复
热议问题