public async Task<IRedisResponse> SendAsync(ICommand command) { var enteredSemaphore = false; IConnection connection = null; try { enteredSemaphore = await _semaphore.WaitAsync(_poolConfiguration.WaitForConnectionTimeoutInMilliseconds); if (!enteredSemaphore) throw ExceptionBecause.Pooling.WaitedTooLongForAvailableConnection(); if (!_connections.TryDequeue(out connection)) throw ExceptionBecause.Pooling.DidNotFindNextConnection(); return await command.SendAsync(connection); } catch (Exception e) { Console.WriteLine("ECONN: " + e.Message); throw; } finally { if (connection != null) _connections.Enqueue(connection); if (enteredSemaphore) _semaphore.Release(); } }