Npgsql.NpgsqlConnector.ReleaseResources C# (CSharp) Method

ReleaseResources() private method

This method is responsible for releasing all resources associated with this Connector.
private ReleaseResources ( ) : void
return void
        internal void ReleaseResources()
        {
            if (_connection_state != ConnectionState.Closed)
            {
                if (SupportsDiscard)
                {
                    ReleaseWithDiscard();
                }
                else
                {
                    ReleasePlansPortals();
                    ReleaseRegisteredListen();
                }
            }
        }

Usage Example

        /// <summary>
        /// Put a pooled connector into the pool queue.
        /// </summary>
        /// <param name="Connector">Connector to pool</param>
        private void UngetPooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector)
        {
            ConnectorQueue Queue;

            // Find the queue.
            Queue = (ConnectorQueue)PooledConnectors[Connector.ConnectionString.ToString()];

            if (Queue == null)
            {
                return; // Queue may be emptied by connection problems. See ClearPool below.
            }
            Connector.CertificateSelectionCallback  -= Connection.CertificateSelectionCallbackDelegate;
            Connector.CertificateValidationCallback -= Connection.CertificateValidationCallbackDelegate;
            Connector.PrivateKeySelectionCallback   -= Connection.PrivateKeySelectionCallbackDelegate;

            Queue.UseCount--;

            if (!Connector.IsInitialized)
            {
                if (Connector.Transaction != null)
                {
                    Connector.Transaction.Cancel();
                }

                Connector.Close();
            }
            else
            {
                if (Connector.Transaction != null)
                {
                    try
                    {
                        Connector.Transaction.Rollback();
                    }
                    catch
                    {
                        Connector.Close()
                        ;
                    }
                }
            }

            if (Connector.State == System.Data.ConnectionState.Open)
            {
                // Release all resources associated with this connector.
                Connector.ReleaseResources();

                Queue.Enqueue(Connector);
            }
        }
All Usage Examples Of Npgsql.NpgsqlConnector::ReleaseResources