【发布时间】:2015-07-09 16:56:09
【问题描述】:
我想使函数异步,因为我想将结果返回到 UI 并且不想让这个挂起,但无论如何都是这样。
谁能告诉我为什么会挂起?
public ActionResult Index()
{
return View(FunctionThreeAsync().Result);
}
private async Task<MyType> FunctionThreeAsync()
{
return await FunctionThree();
}
private Task<MyType> FunctionThree()
{
return Task.Run<MyType>(() => { /* code */ });
}
【问题讨论】:
-
返回视图(await FunctionThreeAsync());
标签: c# asynchronous async-await task-parallel-library task