【发布时间】:2020-01-20 12:29:52
【问题描述】:
所以我有一个关于任务和异步/等待操作的问题。
我有这样的方法:
public Task<IActionResult> PostCompleteFormModel(string name, [FromBody]IndicatorFormApi apiModel, Guid participantId, [FromServices] IChallengeCycleService challengeCycleService)
{
return Post(name, apiModel.ToSubmitApi(), participantId, challengeCycleService);
}
在控制器中。
如您所见,它没有 async/await。
但是这样做不是更好吗:
public async Task<IActionResult> PostCompleteFormModel(string name, [FromBody]IndicatorFormApi apiModel, Guid participantId, [FromServices] IChallengeCycleService challengeCycleService)
{
return await Post(name, apiModel.ToSubmitApi(), participantId, challengeCycleService);
}
那么使用 async/await 关键字?
还是没有区别?
谢谢
【问题讨论】:
标签: c# multithreading .net-core