Working with WebClient object and Timeout

יום שלישי, אפריל 3, 2012

Hi,The WebClient object in .NET doesn't expose the request TimeOut property.In case you decided to use this object it is better to inherit from it and expose the TimeOut property.  Example: public class SearchWebClient : WebClient { public SearchWebClient() { Timeout = 2000; } public SearchWebClient(int timeout) { Timeout = timeout; } ///<summary> /// Request timeout in milliseconds ///</summary> public int Timeout { get; set; } protected override WebRequest GetWebRequest(Uri address) { WebRequest result = base.GetWebRequest(address); ...
no comments