0
votes

I am trying to make a generic connectivity class in my Windows Phone 8 app. This class should be used whenever i need to send a POST request to the service.

In a particular use case i need to call the service, display the response and navigate the user away from the current page.

I am able to successfully achieve the first 2 objectives using the connectivity class. This is because the connectivity class is not part of the UI. So is there a way the GetResponseCallBack method can inform the calling method that it has received the response and then i can navigate the user?

Hope i was able to ask my question clearly.

Thanks!

1
In the last project i worked on I always had to wait for the response from the server in oder to do that I made a method for this called GetResponseAsync which is an Task returning method that create a TaskCompletionSource that is setted in the responseCallbackFabio Marcolini

1 Answers

0
votes

I have managed to find a work-around for now. Not sure if it is the right way to get the response of the async task. But i am sharing it for the benefit for others who may be facing similar issue.

What i have done is, i have defined the GetResponseCallBack as a public method in the class calling the async task method. Later i pass the same GetResponseCallBack as a parameter to the beginGetResponse method in the GetRequestStreamCallBack method.

This way i am able to bring the control flow back to the phoneApplicationPage after the asyncTask executes, thus allowing me to handle some events on the UI thread.

Hope it helps!