static void ProxyValidateCallback(IAsyncResult ar) { AsyncResult result = (AsyncResult)ar; Func <string, int, string, bool> func = (Func <string, int, string, bool>)result.AsyncDelegate; var isValid = func.EndInvoke(ar); var proxyItems = (object[])ar.AsyncState; string ip = (string)proxyItems[0]; int port = (int)proxyItems[1]; string proxySite = (string)proxyItems[2]; OnProxyValidated(ip, port, proxySite, isValid); if (isValid) { ProxyCache.AddProxy(ip, port, proxySite); } }
public static void BeginCrawl() { ProxyCache.Clear(); ProxyCrawlResult.Clear(); _tmrGetProxy = new System.Threading.Timer(new TimerCallback(CrawlProxy), null, 0, 1000 * 60 * 30); }
public static void RemoveProxy(WebProxy webProxy) { ProxyCache.RemoveProxy(webProxy.Address.Host, webProxy.Address.Port); }
public static WebProxy GetRandomProxy() { return(ProxyCache.GetRandomProxy()); }