You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
924 B
C#
47 lines
924 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ZJ_BYD.Common
|
|
{
|
|
public class MyWebClient : WebClient
|
|
{
|
|
private int _timeout;
|
|
|
|
/// <summary>
|
|
/// 超时时间(毫秒)
|
|
/// </summary>
|
|
public int Timeout
|
|
{
|
|
get
|
|
{
|
|
return _timeout;
|
|
}
|
|
set
|
|
{
|
|
_timeout = value;
|
|
}
|
|
}
|
|
|
|
public MyWebClient()
|
|
{
|
|
this._timeout = 60000;
|
|
}
|
|
|
|
public MyWebClient(int timeout)
|
|
{
|
|
this._timeout = timeout;
|
|
}
|
|
|
|
protected override WebRequest GetWebRequest(Uri address)
|
|
{
|
|
var result = base.GetWebRequest(address);
|
|
result.Timeout = this._timeout;
|
|
return result;
|
|
}
|
|
}
|
|
}
|