I have a question regarding SignalR's official documentation - Hubs API Guide - .NET Client. In the section - How to establish a connection. It has been written the following thing:
The Start method executes asynchronously. To make sure that subsequent lines of code don't execute until after the connection is established, use await in an ASP.NET 4.5 asynchronous method or .Wait() in a synchronous method. Don't use .Wait() in a WinRT client.
Does anyone know what is the specific reason not to call Wait()? Also, does also this apply when I have a WinRT client where I have a call with hubProxy.Invoke()
to the server?
Thank you for your help!
From the comment:
In a client-side UI app (including WinRT), there're at least two reason to not block:
await
in the current chain of calls, on the upper stack frame;The latter is especially important for WinRT, where asynchrony is pervasive. The whole WinRT framework has been designed to be "async all the way down", so it's very likely you'd create a deadlock if you use
task.Wait
ortask.Result
anywhere on the UI thread.For a server-side ASP.NET app, there're also at least two reasons to not block:
You may want to go through the list of links in
async-await
wiki for further reading materials.