Код: Выделить всё
public static class SignalMethods
{
public static Task SendMessageAsync(this IHubContext hub, IEnumerable users, string method, string origin, string message)
{
return hub.Clients.Users(users).SendAsync(method, new MyMessage(origin, message));
}
public static void SendMessage(this IHubContext hub, IEnumerable users, string method, string origin, string message)
{
hub.Clients.Users(users).SendAsync(method, new MyMessage(origin, message));
}
}
< /code>
влияет ли это на то, как он ведет себя (или влияет на производительность), если я называю один или другой метод из несинхрочного сервиса в моем приложении? Ниже приведены 2 возможные вызовы < /p>
_hubContext.SendMessageAsync(users, "my method async", "me", "test 1");
_hubContext.SendMessage(users, "my method", "me", "test 2");
< /code>
Я предполагаю, что я также могу позвонить SendmessageAsync, ожидая звонка таким: < /p>
await _hubContext.SendMessageAsync(users, "my method async", "me", "test 1");
Подробнее здесь: https://stackoverflow.com/questions/794 ... c-vs-async