I read your post, and suggest you to first you go through the synchronous and then you go for the asynchronous response method. There is script that I used for the synchronous response in my windows Silverlight phone. Try with this one; it might be also works in the windows 7 phone. Here instead of calling the function I returned the value to the desired place of the web service. Then you make the call function to delegate the service and after that you call that function to invoke the operation.
Code:
void DoSomethingAsync( Action<string> callback ) {
HttpWebRequest req; // TODO: build your request
req.BeginGetResponse( result => {
// This anonymous function is a closure and has access
// to the containing (or enclosing) function.
var response = req.EndGetResponse( result );
// Get the result string and call the callback
string resultString = null; // TODO: read from the stream
callback(resultString);
}, null );
}
Script for call the function.
Code:
void btnGo_Click( object sender, EventArgs e ) {
DoSomethingAsync( resultString => {
// This anonymous function is called when the web request has
// finished and has your string.
// Now that we have the string, we can go and process it.
ProcessWebResponseResult( resultString );
});
}
Bookmarks