MethodInvoker vs Action for Control.BeginInvoke

后端 未结 7 936
走了就别回头了
走了就别回头了 2020-11-28 22:33

Which is more correct and why?

Control.BeginInvoke(new Action(DoSomething), null);

private void DoSomething()
{
    MessageBox.Show(\"What a great post\");
         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 23:12

    I prefer using lambdas and Actions/Funcs:

    Control.BeginInvoke(new Action(() => MessageBox.Show("What a great post")));
    

提交回复
热议问题