给定
static void Main()
{
Form f = new Form();
f.Show();
Action a = () => MessageBox.Show("hi");
Task.Factory.FromAsync(f.BeginInvoke(a), (ar) => a.EndInvoke(ar));
Console.Read();
}
- 我从来没有看到消息框显示“嗨”。
- 其次,从 Async 使用 Task.Factory 时还需要调用EndInvoke(ar)吗?