Skip to content

Instantly share code, notes, and snippets.

@lmatt-bit
Last active December 17, 2015 05:48
Show Gist options
  • Select an option

  • Save lmatt-bit/5560147 to your computer and use it in GitHub Desktop.

Select an option

Save lmatt-bit/5560147 to your computer and use it in GitHub Desktop.
WebClient Timeout setting
public class WebDownload : WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public WebDownload()
{
this._timeout = 60000;
}
public WebDownload(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment