/// <summary> /// 检测代理 /// </summary> /// <param name="testThread"></param> /// <param name="proxy"></param> private static void Testing(TestThread testThread, HttpProxy proxy) { var sw = new Stopwatch(); sw.Start(); var result = _testProxyHelper.TestProxy(proxy); sw.Stop(); #region var testResult = result.IsAlive; testThread.Description = proxy.IpAndPort + (testResult ? " Alive " : " Dead ") + sw.ElapsedMilliseconds + "ms"; var model = ProxyData.GetCopy(proxy.Ip, proxy.Port); try { if (model != null) { if (Config.LocalSetting.CheckArea) { var location = SearchIp(proxy.Ip); model.country = location; } if (testResult) { model.response = int.Parse(sw.ElapsedMilliseconds.ToString("F0")); model.testdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); model.description = string.Format("{0} {1}", model.testdate, sw.ElapsedMilliseconds.ToString("F0") + "ms"); model.status = 1; } else { model.description = Config.LocalLanguage.Messages.ProxyIsDead + sw.ElapsedMilliseconds.ToString("F0") + "ms"; model.response = 99999; model.status = 0; model.testdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } ProxyData.Set(model); } } catch { ProxyData.Remove(model); } #endregion }