//单个查询的回调函数 public void CallbackFuction(IAsyncResult result) { int num = 0; string strResult = string.Empty; string temp = string.Empty; GetWebClientHandler handler = (GetWebClientHandler)((AsyncResult)result).AsyncDelegate; string[] html = handler.EndInvoke(result); //处理返回的结果 if (html[0] == "false") { this.txtResult.AppendText("\r\nIP被封!\r\n"); return; } temp = Tools.Google_getProductNum(html[1]); num = (temp == string.Empty ? 0 : Convert.ToInt32(temp)); if (num == 0) { strResult = "没有收录"; } else { strResult = num.ToString(); } this.txtResult.AppendText("结果:\r\t" + strResult + Environment.NewLine); this.txtResult.AppendText(result.AsyncState.ToString()); }
//排名回调 public void CallbackFuctionGrankings(IAsyncResult result) { string strResult = string.Empty; string[] html = null; GetWebClientHandler handler = (GetWebClientHandler)((AsyncResult)result).AsyncDelegate; html = handler.EndInvoke(result); if (html[0] == "false") { this.txtResult.AppendText("\r\nIP已经被封掉了\r\n"); return; } List <string> alist = GetUrlList(html[1]);//代码中已经转换为小写了 int ranknum = 0; strResult = Computingrankings(alist, this.comDomainItems.Text, out ranknum); this.txtResult.AppendText(strResult); }