I’m working with a web service I didn’t write myself (and so cannot edit). I have this code:
public void GetData()
{
try
{
TelemeterServiceClient client = new TelemeterServiceClient();
RetrieveUsageRequestType request = new RetrieveUsageRequestType { UserId = Username, Password = Password };
RetrieveUsageResponseType response = client.retrieveUsage(request);
Result = response.Item;
Callback(null);
}
catch (Exception e)
{
Result = null;
Callback(e);
}
}
This works fine in a WPF project. However, I’m now working with a Windows Phone project, which uses Silverlight. In this project, the retrieveUsage()-method cannot be found.
Apparently Silverlight only supports asynchronous calls to web services. And indeed, there is a retrieveUsageAsync()-method present.
But how do I use this method and get the result back? Can someone provide me a simple example of how to use async calls?
Thanks
here’s an example:
Think it’s translated to c# like this:
In the line with
action, action stands for a delegate or action where you handle your async resultLet me know if you have troubles translating this into c# then i’ll change it 😉