相关疑难解决方法(0)

MethodInvoker与Control.BeginInvoke的Action

哪个更正确,为什么?

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

private void DoSomething()
{
    MessageBox.Show("What a great post");
}
Run Code Online (Sandbox Code Playgroud)

要么

Control.BeginInvoke((MethodInvoker) delegate { 
    MessageBox.Show("What a great post");
}); 
Run Code Online (Sandbox Code Playgroud)

我觉得我在做同样的事情,所以什么时候适合使用MethodInvokervs Action,甚至写一个lambda表达式?

编辑:我知道写一个lambda vs之间并没有什么区别Action,但MethodInvoker似乎是出于特定目的.它有什么不同吗?

.net c# delegates invoke

56
推荐指数
4
解决办法
5万
查看次数

标签 统计

.net ×1

c# ×1

delegates ×1

invoke ×1