private async Task PrunePoolAsync(CancellationToken cancellationToken) { bool enteredPool = false; try { // if it takes too long to enter the pool, then the pool is fully utilized // and we don't want to mess with it. enteredPool = await _poolQueue.WaitAsync(TimeSpan.FromMilliseconds(20), cancellationToken).ConfigureAwait(false); if (!enteredPool) { return; } _connectionHolder.Prune(); } finally { if (enteredPool) { try { _poolQueue.Release(); } catch { // log this... it's a bug } } } }