c# - How to perform a web service call in Windows Phone -


i developping in windows phone 7.1, have web services calls json string, use following code (that class):

public void getregions()         {             if (!_wc.isbusy)             {                 _wc.downloadstringasync(new uri("http://lapiazzashopping.it/test/mobile/getregions.php"));                 _wc.downloadstringcompleted += new downloadstringcompletedeventhandler(wc_downloadstringcompleted_regions);             }         }          private void wc_downloadstringcompleted_regions(object sender, downloadstringcompletedeventargs e)         {             debug.writeline("web service says: " + e.result);             regions = jsonconvert.deserializeobject<ilist<regions>>(e.result);         } 

now after call want change page show result json. if start call button , button same page change compiler changes page call not yet completed because cannot manage methode "wc_downloadstringcompleted_regions" methode calle authomatically compiler @ end of call, issue cannot know when call completed , cannot know when change page @ right moment.

is there solution can permit me "pause" code until call , deserializion completed??

thanks

add eventhandler (_wc.downloadstringcompleted) before web call.

also since calling async method should doing

await _wc.downloadstringasync(....

otherwise it's not async @ all, , method should written async keyword. think need read on async knowledge.

here's guide go through: http://msdn.microsoft.com/en-us/library/hh191443.aspx


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -