Reputation:
SignalR client hangs on wait();
Here is my code
Proxy.Invoke<string>("IO_Table_Game_Status", getTableGameStateJsonReq).ContinueWith((responseJson) =>
{
string tablestatusResp = responseJson.Result;
}).Wait();
Here I need to get the Json value in tablestatusResp
. But it's showing empty value.
Upvotes: 1
Views: 1898
Reputation: 337
I got this when my hub was not being initialized correctly. Try to create a raw Hub, with a clean constructor and a simple method to see if it keeps hanging.
Upvotes: 0
Reputation:
Thank you, Finally i got answer to my question... i have used Dispatcher. here is the code
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
{
string tablestatusResp = Get_Info_Panel_Proxy.Invoke<string>("IO_Table_Game_Status", getTableGameStateJsonReq).Result;
}));
Upvotes: 0
Reputation: 16
var data=Proxy.Invoke<string>("IO_Table_Game_Status", getTableGameStateJsonReq).Result;
Hope this help you.
Upvotes: 0
Reputation: 3589
Since (from what I can tell) SignalR is exposing access to a true asynchronous operation (looks like it's sending HTTP messages), I think it'd be best if you let your application leverage this asynchronicity. It makes for easier to maintain and understand code, and it saves you from the bajillion pitfalls when it comes to deadlocks on blocking calls when using the Wait method and it's siblings.
public async Task<TReturnType> YourCurrentMethod()
{
var tableStatusResp await Proxy.Invoke<string>("IO_Table_Game_Status", getTableGameStateJsonReq);
}
Note that the method signature is made up by me, all you have to do is to mark it as async
so you can use the await
keyword.
Upvotes: 1