public static AsyncSemaphore GetSemaphoreForProxy(FUTProxy proxy) { AsyncSemaphore returnType = null; lock (_lock) { if (_loginSemaphores == null) { _loginSemaphores = new Dictionary <string, AsyncSemaphore>(); } if (proxy == null) { returnType = GetSemaphoreForExe(); } else { if (!_loginSemaphores.ContainsKey(proxy.ToString())) { _loginSemaphores.Add(proxy.ToString(), new AsyncSemaphore(1)); } returnType = _loginSemaphores[proxy.ToString()]; } } return(returnType); }
public static void RemoveFUTProxy(FUTProxy proxy) { lock (_locker) { _futProxies.RemoveAll(x => x.First.ToString() == proxy.ToString()); } }
public static FUTProxy GetFUTProxy(FUTProxy pre) { lock (_locker) { if (pre != null) { var preFound = _futProxies.FirstOrDefault(x => x.First.ToString() == pre.ToString()); if (preFound != null) { preFound.Second++; return(preFound.First); } } foreach (var futProxy in _futProxies) { if (futProxy.Second < _maxCounter) { futProxy.Second++; return(futProxy.First); } } return(null); } }