【发布时间】:2011-05-08 13:38:45
【问题描述】:
ThreadPool.QueueUserWorkItem(x =>
{
//get dataset from web service
BeginInvoke(new Action(() => {
//fill grid
}));
BeginInvoke(new MethodInvoker(() => {
//fill grid
}));
});
在 C# 2.0 中,我使用分配 MethodInvoker 从后台线程更新 UI,在 BeginInvoke 下使用时切换到 Action 是否明智?使用 Action 是否更快或更安全?
【问题讨论】:
-
类似的问题已经在 stackoverflow stackoverflow.com/questions/1167771/…987654322@ 上提出并回答
-
人们建议他两者都不使用,这让我有点困惑。他们使用的 C# 编译器与我不同吗?我的让我传递来自
System.Delegate的东西。见stackoverflow.com/questions/253138/…