I am making a REST call, the server side response is in the form of an XML. I am making this call asynchronously. I've test it as a Console application and it works as it should. However, when I test it on the XBOX , the asynchronous request is never completed. My processVideo method parses the XML and places the items into a List. I needed to reference this List from another class so I added (result.IsCompleted == false) to ensure that asynchronous call is completed before I reference and utilize the List. It seems that the asynchronous request is never completed and locks UI, any ideas?
public void initilaizeRest()
{
WebRequest request = HttpWebRequest.Create(URI);
request.Method = GET;
// RequestState is a custom class to pass info to the callback
RequestState state = new RequestState(request, URI);
IAsyncResult result = request.BeginGetResponse(new AsyncCallback(getVideoList), state);
Logger.Log("Querystate :"+QUERYSTATE+" URI:"+URI);
/// Wait for aynchronous response to be completed
while (result.IsCompleted == false)
{
Logger.Log("Sleeping");
Thread.Sleep(100);
}
}
public void getVideoList(IAsyncResult result)
{
RequestState state = (RequestState)result.AsyncState;
WebRequest request = (WebRequest)state.Request;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
//Process response
switch (QUERYSTATE)
{
case (int)Querystate.SERIESQUERY:
Logger.Log("Processing series state");
processSeries(response);
break;
case (int)Querystate.VIDEOQUERY:
Logger.Log("Processing video state");
processVideo(response);
break;
}
}
public void processVideo(HttpWebResponse response)
{
//parses XML into an object and places items in a LIST
}