protected override void DisposeAll() { if (!PoolInitialized) { return; } PoolSuspended = true; foreach (var pool in Pools) { ConnectionStringPoolableBase poolItem; while (pool.Value.TryDequeue(out poolItem)) { poolItem.Dispose(true); } } Pools.Clear(); foreach (var semaphoreSlim in Semaphores) { if (semaphoreSlim.Value.CurrentCount > 0) { try { semaphoreSlim.Value.Release(semaphoreSlim.Value.CurrentCount); } catch { } } try { semaphoreSlim.Value.Dispose(); } catch { } } Semaphores.Clear(); PoolInitialized = false; PoolSuspended = false; }
/// <summary> /// Remove all semaphores and guards from the instance. This is only usable for visualization purposes. /// </summary> public void VisClearSemaphores() { Semaphores.Clear(); }