Esempio n. 1
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="TimestampTest"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                try
                {
                    if (disposing)
                    {
                        // Dispose timestamp service.
                        if (m_timestampService != null)
                        {
                            m_timestampService.ServiceProcessException -= m_timestampService_ServiceProcessException;
                            m_timestampService.Dispose();
                        }
                        m_timestampService = null;

                        // Dispose purge timer.
                        if (m_purgeTimer != null)
                        {
                            m_purgeTimer.Elapsed -= m_purgeTimer_Elapsed;
                            m_purgeTimer.Dispose();
                        }
                        m_purgeTimer = null;

                        // Dispose warning timer.
                        if (m_warningTimer != null)
                        {
                            m_warningTimer.Elapsed -= m_warningTimer_Elapsed;
                            m_warningTimer.Dispose();
                        }
                        m_warningTimer = null;

                        // Dispose discarding adapter.
                        if (m_discardingAdapter != null)
                        {
                            m_discardingAdapter.DiscardingMeasurements -= m_discardingAdapter_DiscardingMeasurements;
                            m_discardingAdapter.Disposed -= m_discardingAdapter_Disposed;
                        }
                        m_discardingAdapter = null;
                    }
                }
                finally
                {
                    m_disposed = true;          // Prevent duplicate dispose.
                    base.Dispose(disposing);    // Call base class Dispose().
                }
            }
        }