可能重复:
MethodInvoker vs Action for Control.BeginInvoke我应该使用MethodInvoker或行动
ThreadPool.QueueUserWorkItem(x =>
{
//get dataset from web service
BeginInvoke(new Action(() => {
//fill grid
}));
BeginInvoke(new MethodInvoker(() => {
//fill grid
}));
});
在C#中我用配发的MethodInvoker更新从后台线程的UI 2.0,将它在BeginInvoke下使用时切换到Action是明智的吗?使用Action更快还是更安全?
我对那些暗示他不使用的人感到困惑。他们使用的是不同于我的C#编译器吗?我使我传递了从'System.Delegate'派生的东西。请参阅http://stackoverflow.com/questions/253138/anonymous-method-in-invoke-call/253150#253150 – mquander 2010-11-11 16:13:03
一个类似的问题已被问及在这里回答stackoverflow http://stackoverflow.com/questions/1167771/ methodinvoker-VS-行动对控制的BeginInvoke – Sam 2010-11-11 16:07:49