public void Dispose() { var dispose = false; lock (_poolState) { dispose = _poolState.TransitionState(State.Disposed); } if (dispose) { if (_closingEventHandler != null) { _closingEventHandler(new ConnectionPoolClosingEvent(_serverId)); } _connectionHolder.Clear(); _maintenanceHelper.Dispose(); _maxConnectionsQueue.Dispose(); _maxConnectingQueue.Dispose(); if (_closedEventHandler != null) { _closedEventHandler(new ConnectionPoolClosedEvent(_serverId)); } } }
public void Dispose() { if (_state.TryChange(State.Disposed)) { if (_closingEventHandler != null) { _closingEventHandler(new ConnectionPoolClosingEvent(_serverId)); } _connectionHolder.Clear(); _maintenanceCancellationTokenSource.Cancel(); _maintenanceCancellationTokenSource.Dispose(); _poolQueue.Dispose(); _waitQueue.Dispose(); _connectingQueue.Dispose(); if (_closedEventHandler != null) { _closedEventHandler(new ConnectionPoolClosedEvent(_serverId)); } } }