MyWebClient.cs 734 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Net;
  3. namespace Muchinfo.MTPClient.Infrastructure.Utilities
  4. {
  5. public class MyWebClient : WebClient
  6. {
  7. private int _timeOut;
  8. public int TimeOut
  9. {
  10. get
  11. {
  12. return _timeOut;
  13. }
  14. set { _timeOut = value; }
  15. }
  16. public MyWebClient()
  17. {
  18. this._timeOut = 30*1000;
  19. }
  20. public MyWebClient(int timeOut)
  21. {
  22. this._timeOut = timeOut;
  23. }
  24. protected override WebRequest GetWebRequest(Uri address)
  25. {
  26. var result = base.GetWebRequest(address);
  27. result.Timeout = this.TimeOut;
  28. return result;
  29. }
  30. }
  31. }