Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public static void BeginCrawl()
 {
     ProxyCache.Clear();
     ProxyCrawlResult.Clear();
     _tmrGetProxy = new System.Threading.Timer(new TimerCallback(CrawlProxy), null, 0, 1000 * 60 * 30);
 }
Exemplo n.º 3
0
 public static void RemoveProxy(WebProxy webProxy)
 {
     ProxyCache.RemoveProxy(webProxy.Address.Host, webProxy.Address.Port);
 }
Exemplo n.º 4
0
 public static WebProxy GetRandomProxy()
 {
     return(ProxyCache.GetRandomProxy());
 }