views:

64

answers:

1

I have some old code that I'm converting to use in Windows Phone. The old code was :

private String Post(string url, string Data) { return webClient.UploadString(url, "POST", Data); }

The problem is there isn't a function called UploadString in webClient. Instead, it's the asynchronous one (UploadStringAsync). How can I convert the above old code to immediately return a string response as UploadString used to do ?

+3  A: 

You can't. Silverlight doesn't support synchronous network operations. You'll need to refactor your code. There are hacks involving wait handles that may still technically work but relying on them is unwise.

Josh Einstein