andrew4582

Web Client With Timeout

Oct 27th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3.  
  4. namespace Common
  5. {
  6.     public class WebClientWTimeout : WebClient
  7.     {
  8.         int _timeout;
  9.         public WebClientWTimeout(int timeout)
  10.         {
  11.             _timeout = timeout;
  12.         }
  13.  
  14.         protected override WebRequest GetWebRequest(Uri address)
  15.         {
  16.             var wreq = base.GetWebRequest(address);
  17.             wreq.Timeout = _timeout;
  18.             return wreq;
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment