Exemple #1
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="FileImporter"/> 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)
                    {
                        if ((object)m_fileSystemWatcher != null)
                        {
                            m_fileSystemWatcher.Created -= m_fileSystemWatcher_Created;
                            m_fileSystemWatcher.Renamed -= m_fileSystemWatcher_Renamed;
                            m_fileSystemWatcher.Dispose();
                        }
                        m_fileSystemWatcher = null;

                        if (UseHighResolutionInputTimer)
                        {
                            PrecisionInputTimer.Detach(ref m_precisionTimer);
                        }
                        else if ((object)m_looseTimer != null)
                        {
                            m_looseTimer.Stop();
                            m_looseTimer.Dispose();
                        }
                        m_looseTimer = null;

                        if ((object)m_fileStream != null)
                        {
                            m_fileStream.Close();
                            m_fileStream.Dispose();
                        }
                        m_fileStream = null;

                        if ((object)m_fileProcessQueue != null)
                        {
                            m_fileProcessQueue.ProcessException -= m_fileProcessQueue_ProcessException;
                        }

                        m_fileProcessQueue = null;

                        // Clear minimum timer resolution.
                        PrecisionTimer.ClearMinimumTimerResolution(1);
                    }
                }
                finally
                {
                    m_disposed = true;          // Prevent duplicate dispose.
                    base.Dispose(disposing);    // Call base class Dispose().
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="CsvInputAdapter"/> 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)
                    {
                        if (UseHighResolutionInputTimer)
                        {
                            PrecisionInputTimer.Detach(ref m_precisionTimer);
                        }
                        else if ((object)m_looseTimer != null)
                        {
                            m_looseTimer.Stop();
                            m_looseTimer.Dispose();
                        }
                        m_looseTimer = null;

                        if ((object)m_inStream != null)
                        {
                            m_inStream.Close();
                            m_inStream.Dispose();
                        }

                        m_inStream = null;

                        // Clear minimum timer resolution.
                        PrecisionTimer.ClearMinimumTimerResolution(1);
                    }
                }
                finally
                {
                    m_disposed = true;          // Prevent duplicate dispose.
                    base.Dispose(disposing);    // Call base class Dispose().
                }
            }
        }