【发布时间】:2015-06-14 02:14:38
【问题描述】:
为什么 B 运行同步? Vs 说。“由于不等待此调用,因此在调用完成之前继续执行当前方法。” ;
A) Task.Factory.StartNew(() => Funcation(1, 1)); //Runs Async
B) Funcation(1, 1); // Says it runs async in vs, but really runs sync.
C) var handleOne = Task.Run(() =>
{
Funcation(1, 1);
}); // Runs Async
D) await Task.Factory.StartNew(() => Funcation(1, 1)); //awaits correctly
E) await Funcation(1, 1); //awaits correctly
static private async Task<int> Funcation(int x, int y)
{
Task.Delay(1000).Wait();
}
【问题讨论】:
标签: c# .net async-await