I have some old code that I'm converting to use in Windows Phone. The old code was :
private String Post(st开发者_如何学Goring 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 ?
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.
精彩评论