// Monitors for roll-over notifications private void m_rolloverWatcher_Elapsed(object sender, ElapsedEventArgs e) { // Don't start another rollover activity if one is already in progress... if (Monitor.TryEnter(m_watcherLock)) { try { // Read the inter-process communications file for changes in roll-over state if ((object)m_archiveFile != null && (object)m_archiveFile.IntercomFile != null && m_archiveFile.IntercomFile.IsOpen) { m_archiveFile.IntercomFile.Load(); IntercomRecord record = m_archiveFile.IntercomFile.Read(1); if ((object)record != null) { // Pause processing if (record.RolloverInProgress && m_archiveFile.IsOpen) { // Notify internal archive file components about the pending rollover m_archiveFile.RolloverWaitHandle.Reset(); // Raise roll-over start event (sets m_rolloverInProgress flag) m_archiveFile.OnRolloverStart(); // Wait for pending to reads to yield m_archiveFile.WaitForReadersRelease(); // Close the active archive file stream so it can be rolled-over m_archiveFile.CloseStream(); } // Resume processing if (!record.RolloverInProgress && !m_archiveFile.IsOpen) { // Open new active archive file stream m_archiveFile.OpenStream(); // Raise roll-over complete event (resets m_rolloverInProgress flag) m_archiveFile.OnRolloverComplete(); // Notify waiting internal archive components that rollover is complete m_archiveFile.RolloverWaitHandle.Set(); } } } } catch (ThreadAbortException) { throw; } catch (Exception ex) { OnDataReadException(new InvalidOperationException("Exception encountered during roll-over processing: " + ex.Message, ex)); } finally { Monitor.Exit(m_watcherLock); } } }