I have the problem that a synchronous HttpWebRequest get stucked after disabling the network connection. It will not return unless i use the debugger. For your interest i am not able to use asynchronous HttpWebRequest because the requests have to be handled recursively.
This method is called from a thread:
private void DoWork()
{
...
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
httpWebRequest.Method = WebRequestMethods.Http.Get;
var response = (HttpWebResponse)request.GetResponse();
...
}
Thread starting:
var workerThread = new Thread(DoWork)
{
IsBackground = true
};
workerThread.Start();
GetResponse is never returning.
Is there a way to cancel the request if i recognize that the network connection got lost or have do i have to live with the problem until we found a asynchronous solution?