I\'m making a request to a remote web server that is currently offline (on purpose).
I\'d like to figure out the best way to time out the request. Basically if the
Html Agility Pack is open souce. Thats why you may modify source yurself. For first add this code to class HtmlWeb:
private int _timeout = 20000;
public int Timeout
{
get { return _timeout; }
set
{
if (_timeout < 1)
throw new ArgumentException("Timeout must be greater then zero.");
_timeout = value;
}
}
Then find this method
private HttpStatusCode Get(Uri uri, string method, string path, HtmlDocument doc, IWebProxy proxy, ICredentials creds)
and modify it:
req = WebRequest.Create(uri) as HttpWebRequest;
req.Method = method;
req.UserAgent = UserAgent;
req.Timeout = Timeout; //add this
Or something like that:
htmlWeb.PreRequest = request =>
{
request.Timeout = 15000;
return true;
};