Npgsql.NpgsqlConnector.RemoveNotificationThread C# (CSharp) Method

RemoveNotificationThread() private method

private RemoveNotificationThread ( ) : void
return void
        internal void RemoveNotificationThread()
        {
            // Wait notification thread finish its work.
            lock (_socket)
            {
                // Kill notification thread.
                _notificationThread.Abort();
                _notificationThread = null;

                // Special case in order to not get problems with thread synchronization.
                // It will be turned to 0 when synch thread is created.
                _notificationThreadStopCount = 1;
            }
        }

Usage Example

示例#1
0
        /// <summary>
        /// Releases the connection to the database.  If the connection is pooled, it will be
        ///	made available for re-use.  If it is non-pooled, the actual connection will be shutdown.
        /// </summary>
        public override void Close()
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Close");

            if (connector != null)
            {
                Promotable.Prepare();
                // clear the way for another promotable transaction
                promotable = null;

                connector.Notification -= NotificationDelegate;
                connector.Notice       -= NoticeDelegate;
                connector.StateChanged -= connector_StateChanged;

                if (SyncNotification)
                {
                    connector.RemoveNotificationThread();
                }

                if (Pooling)
                {
                    NpgsqlConnectorPool.ConnectorPoolMgr.ReleaseConnector(this, connector);
                }
                else
                {
                    Connector.ProvideClientCertificatesCallback -= ProvideClientCertificatesCallbackDelegate;
                    Connector.CertificateSelectionCallback      -= CertificateSelectionCallbackDelegate;
                    Connector.CertificateValidationCallback     -= CertificateValidationCallbackDelegate;
                    Connector.PrivateKeySelectionCallback       -= PrivateKeySelectionCallbackDelegate;

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

                    Connector.Close();
                }


                connector = null;

                this.OnStateChange(new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed));
            }
        }
All Usage Examples Of Npgsql.NpgsqlConnector::RemoveNotificationThread