admin管理员组文章数量:1289911
I have a class with an extension method for signal-r messages in C#:
public static class SignalMethods
{
public static Task SendMessageAsync(this IHubContext<MyHub> hub, IEnumerable<string> users, string method, string origin, string message)
{
return hub.Clients.Users(users).SendAsync(method, new MyMessage(origin, message));
}
public static void SendMessage(this IHubContext<MyHub> hub, IEnumerable<string> users, string method, string origin, string message)
{
hub.Clients.Users(users).SendAsync(method, new MyMessage(origin, message));
}
}
Does it affect how it behaves (or does it affect the performance) if I call one method or the other from a non-async service in my application? Below are the 2 possible calls
_hubContext.SendMessageAsync(users, "my method async", "me", "test 1");
_hubContext.SendMessage(users, "my method", "me", "test 2");
I presume I could also call SendMessageAsync awaiting the call like this:
await _hubContext.SendMessageAsync(users, "my method async", "me", "test 1");
What's the recommended approach?
本文标签: csignalr sync vs asyncStack Overflow
版权声明:本文标题:c# - signal-r sync vs async - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741417627a2377609.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论