1 开始访问
public static void StartAccessingURL(string url,int index)
{
try
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "Get";
webRequest.ContentType = "application/json";
webRequest.Headers.Add("Authorization", "MzQ1"); //token
webRequest.BeginGetResponse(new AsyncCallback(OnOneResponse), webRequest);
}
catch(Exception ex)
{
Log.LogHelper.Error("StartAccessingURL() " + ex.Message);
}
}
2 回调函数
public static void OnOneResponse(IAsyncResult ar)
{
try
{
WebRequest wrq = (WebRequest)ar.AsyncState;
WebResponse wrs = wrq.EndGetRespons