【发布时间】:2016-09-27 05:39:39
【问题描述】:
请考虑这种操作方法:
[HttpPost]
public async Task RemoveUserFromGroups(string connectionId, List<string> groupNames, string pusherAddress)
{
var onlineUser = OnlineUser.Instance;
await OnlineBusiness.RemoveUserFromGroups(onlineUser.Id, onlineUser.CustomerId, onlineUser.IsTrader, connectionId, groupNames, pusherAddress);
}
还有这个方法:
public static Task<bool> RemoveUserFromGroups(int userId, int customerId, bool isTrader, string connectionId, List<string> groupNames, string pusherAddress)
{
return Task.FromResult(PusherBusiness.RemoveUserFromGroups(userId, customerId, isTrader, connectionId, groupNames, pusherAddress));
}
第三方库中的PusherBusiness 类在该类中调用Web 服务。
我想将我的控制器更改为异步模式。使用 Task.FromResult 并返回 Task 然后等待它是否正确?
这是异步的吗?
【问题讨论】:
标签: c# asynchronous async-await