public void SelectNextProxy() { if (_preventDeadLock == WebProxies.Count + 1) { CurrentWebProxy = null; UseProxy = false; _preventDeadLock = 0; return; } WebProxies.Enqueue(WebProxies.Dequeue()); WebProxy webProxy = WebProxies.Peek(); RegCount rc = ProxyRegCounts[webProxy]; if (rc == null || rc.CountRegistrations < AllowReg) { CurrentWebProxy = webProxy; SaveCurrentProxyList(); _preventDeadLock = 0; } else { _preventDeadLock++; SelectNextProxy(); } }
public void SelectNextProxy() { if (_preventDeadLock == WebProxies.Count + 1) { Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); Logger.Info("Закончились прокси сервера на сегодня. Каждый уже зарегил максимум человек."); Logger.Info("Переключаюсь на основной адрес."); Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CurrentWebProxy = null; UseProxy = false; _preventDeadLock = 0; return; } WebProxies.Enqueue(WebProxies.Dequeue()); WebProxy webProxy = WebProxies.Peek(); RegCount rc = ProxyRegCounts[webProxy]; if (rc == null || rc.CountRegistrations < AllowReg) { CurrentWebProxy = webProxy; Logger.Info("SetProxy " + CurrentWebProxy.Address.Host + " " + CurrentWebProxy.Address.Port); SaveCurrentProxyList(); _preventDeadLock = 0; } else { _preventDeadLock++; SelectNextProxy(); } }
// <summary> // Public function to get next proxies in a list // </summary> public void SelectNextProxy() { var taskProxy = new Task(() => { if (_preventDeadLock == WebProxies.Count + 1) { Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); Logger.Info("Закончились прокси сервера на сегодня. Каждый уже зарегил максимум человек."); Logger.Info("Переключаюсь на основной адрес."); Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CurrentWebProxy = null; UseProxy = false; _preventDeadLock = 0; return; } WebProxies.Enqueue(WebProxies.Dequeue()); var webProxy = WebProxies.Peek(); var rc = ProxyRegCounts[webProxy]; if (rc == null || rc.CountRegistrations < AllowReg) { CurrentWebProxy = webProxy; Logger.Info("SetProxy " + CurrentWebProxy.Address.Host + " " + CurrentWebProxy.Address.Port); SaveCurrentProxyList(); _preventDeadLock = 0; } else { _preventDeadLock++; SelectNextProxy(); } }, CancellationToken.None, TaskCreationOptions.AttachedToParent); taskProxy.Start(); taskProxy.Wait(); }