I created a class like below.
public class WebDownload : WebClient
{
private int _timeout;
/// <summary>
/// Time in milliseconds
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public WebDownload()
{
this._timeout = -1;
}
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
When I create an object of this class it creates a webclient object and sets timeout
to -1 so that it waits unlimited time for a response.
But even after I set timeout
to -1 it results in a timeout error.
Is there a solution for this?
ReadWriteTimeout
property, that's becauseReadWriteTimeout
is a property ofHttpWebRequest
, so you probably have to cast toHttpWebRequest
instead ofWebRequest
. – Kashgar