可能重複:
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