MethodInvoker vs Action for Control.BeginInvoke

后端 未结 7 843
走了就别回头了
走了就别回头了 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")));
    
    0 讨论(0)
提交回复
热议问题