Пример #1
0
        /// <summary>
        /// Releases the unmanaged resources used by this <see cref="BroConnection"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                try
                {
#if USE_SAFE_HANDLES
                    if ((object)m_connectionPtr != null && !m_connectionPtr.IsInvalid())
                    {
                        m_connectionPtr.Dispose();
                    }
#else
                    if (m_connectionPtr != IntPtr.Zero)
                    {
                        BroApi.bro_conn_delete(m_connectionPtr);
                        m_connectionPtr = IntPtr.Zero;
                    }
#endif
                }
                finally
                {
                    m_disposed = true;  // Prevent duplicate dispose.
                }
            }
        }