c# - Deadlock when calling async methods on Windows Phone 8 -


my problem following:

on ui thread have button event, call service method:

private async void refreshobjectsbutton_click(object sender, eventargs e) {     var objectservice = new objectservice();     var objects = await objectservice.getobjects(userinfo.token); } 

the service method is:

public class objectservice : serviceclientbase, iobjectservice {     public async task<observablecollection<objectviewmodel>> getobjects(string token)     {         var response = await getasync<observablecollection<hookviewmodel>>("uri_address", token);         return response;     } } 

and getasync method implemented in serviceclientbase:

public async task<t> getasync<t>(string uri, string token) {     using (var client = createclient())     {         try         {             httpresponsemessage response = new httpresponsemessage();             response = await client.getasync(uri);             t retval = default(t);             if (response.issuccessstatuscode)             {                 retval = await response.content.readasasync<t>();             }             return retval;         }         catch (exception ex)         {             //to log exception             return default(t);         }     } } 

when execution reaches getasync<t>(), request sent, result , retval contains list of values. after getasync<t>() execution ends, getobjects() not continue execution anymore. believe it's deadlock explained here. using advices seen in previous link didn't resolve issue. it's i'm missing here. can explain why deadlock happening, , maybe provide further advice in resolving issue?


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -