Last active
December 17, 2015 05:48
-
-
Save lmatt-bit/5560147 to your computer and use it in GitHub Desktop.
WebClient Timeout setting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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