public override void Close() { if (!IsClosed && _innerConnection != null) { lock (this) { try { lock (_innerConnection) { // Close the Remote Event Manager _innerConnection.CloseEventManager(); // Unbind Warning messages event if (_innerConnection.Database != null) { _innerConnection.Database.WarningMessage = null; } // Dispose Transaction _innerConnection.DisposeTransaction(); // Dispose all active statemenets _innerConnection.ReleasePreparedCommands(); // Close connection or send it back to the pool if (_options.Pooling) { if (_innerConnection.CancelDisabled) { // Enable fb_cancel_operation if going into pool _innerConnection.EnableCancel(); } // Send connection to the Pool FbConnectionPoolManager.Instance.Release(_innerConnection); } else { if (!_innerConnection.IsEnlisted) { _innerConnection.Dispose(); } _innerConnection = null; } } } catch { } finally { // Update connection state OnStateChange(_state, ConnectionState.Closed); } } } }
public override void Close() { if (!IsClosed && _innerConnection != null) { try { _innerConnection.CloseEventManager(); if (_innerConnection.Database != null) { _innerConnection.Database.WarningMessage = null; } _innerConnection.DisposeTransaction(); _innerConnection.ReleasePreparedCommands(); if (_options.Pooling) { if (_innerConnection.CancelDisabled) { _innerConnection.EnableCancel(); } if (!_innerConnection.Database.ConnectionBroken) { FbConnectionPoolManager.Instance.Release(_innerConnection); } else { if (!_innerConnection.IsEnlisted) { _innerConnection.Dispose(); } _innerConnection = null; } } else { if (!_innerConnection.IsEnlisted) { _innerConnection.Dispose(); } _innerConnection = null; } } catch { } finally { OnStateChange(_state, ConnectionState.Closed); } } }
internal async Task CloseImpl(AsyncWrappingCommonArgs async) { if (!IsClosed && _innerConnection != null) { try { await _innerConnection.CloseEventManager(async).ConfigureAwait(false); if (_innerConnection.Database != null) { _innerConnection.Database.WarningMessage = null; } await _innerConnection.DisposeTransaction(async).ConfigureAwait(false); await _innerConnection.ReleasePreparedCommands(async).ConfigureAwait(false); if (_options.Pooling) { if (_innerConnection.CancelDisabled) { await _innerConnection.EnableCancel(async).ConfigureAwait(false); } var broken = _innerConnection.Database.ConnectionBroken; FbConnectionPoolManager.Instance.Release(_innerConnection, !broken); if (broken) { await DisconnectEnlistedHelper().ConfigureAwait(false); } } else { await DisconnectEnlistedHelper().ConfigureAwait(false); } } catch { } finally { OnStateChange(_state, ConnectionState.Closed); } } async Task DisconnectEnlistedHelper() { if (!_innerConnection.IsEnlisted) { await _innerConnection.Disconnect(async).ConfigureAwait(false); } _innerConnection = null; } }