I'm trying to use the async HttpWebRequest
in Silverlight for Windows Phone. All works perfect until I get to the where I should call
private static ManualResetEvent allDone = new ManualResetEvent(false);
...
request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
allDone.WaitOne();
Debug.WriteLine("All done!");
In GetResponseCallback
:
private void GetResponseCallback(IAsyncResult asynchronousResult)
{
try
{
request = (HttpWebRequest)asynchronousResult.AsyncState;
response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
allDone.Set();
}
catch (Exception e)
{
Debug.WriteLine("Got Exception in GetResponseCallback: " + e.Message);
}
}
After the call to allDone.WaitOne();
it just hangs...
Any suggestions on why?