hi all since i am new here i hope this is the right place.
i am trying out HttpWebRequest to check out the status code (in this case response) from different websites.
On ok the response is very fast and no form freeze.
On a connect failure the form freezes and take's around 5 seconds
bypassing the freezing can be done with a background worker.
But is there a way to say, there is no response in 1 second, forget this one and go to the next.
thx
i am trying out HttpWebRequest to check out the status code (in this case response) from different websites.
On ok the response is very fast and no form freeze.
On a connect failure the form freezes and take's around 5 seconds
bypassing the freezing can be done with a background worker.
But is there a way to say, there is no response in 1 second, forget this one and go to the next.
C#:
try
{
string url;
url = (LoopUrlFromListboxOrStream ) ; //example
// Creates an HttpWebRequest for the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
// Sends the HttpWebRequest and waits for a response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
label1.Text = (myHttpWebResponse.StatusDescription);
// Releases the resources of the response.
myHttpWebResponse.Close();
}
catch (WebException ex)
{
label2.Text = (ex.Status.ToString());
}
catch (Exception ex)
{
label2.Text = (ex.Message.ToString());
}
thx