static void HandleError(string s)
        {
            string    fullLogFilePath       = null;
            Exception errorWhileWritingFile = null;
            // Atomically captures the LogPath to use.
            string logPath = _logPath;

            if (logPath != null)
            {
                try
                {
                    fullLogFilePath = FileUtil.WriteUniqueTimedFile(logPath + SubDirectoryName, ".txt", DateTime.UtcNow, Encoding.UTF8.GetBytes(s), true);
                }
                catch (Exception ex)
                {
                    errorWhileWritingFile = ex;
                }
            }
            var h = OnError;

            if (h != null)
            {
                LowLevelErrorEventArgs e = new LowLevelErrorEventArgs(s, fullLogFilePath, errorWhileWritingFile);
                // h.GetInvocationList() creates an independent copy of Delegate[].
                foreach (EventHandler <LowLevelErrorEventArgs> d in h.GetInvocationList())
                {
                    try
                    {
                        d(null, e);
                    }
                    catch (Exception ex)
                    {
                        OnError -= (EventHandler <LowLevelErrorEventArgs>)d;
                        ActivityMonitor.CriticalErrorCollector.Add(ex, "While raising SystemActivityMonitor.OnError event.");
                    }
                }
            }
        }
 static void HandleError( string s )
 {
     string fullLogFilePath = null;
     Exception errorWhileWritingFile = null;
     // Atomically captures the LogPath to use.
     string logPath = _logPath;
     if( logPath != null )
     {
         try
         {
             fullLogFilePath = FileUtil.WriteUniqueTimedFile( logPath + SubDirectoryName, ".txt", DateTime.UtcNow, Encoding.UTF8.GetBytes( s ), true );
         }
         catch( Exception ex )
         {
             errorWhileWritingFile = ex;
         }
     }
     var h = OnError;
     if( h != null )
     {
         LowLevelErrorEventArgs e = new LowLevelErrorEventArgs( s, fullLogFilePath, errorWhileWritingFile );
         // h.GetInvocationList() creates an independent copy of Delegate[].
         foreach( EventHandler<LowLevelErrorEventArgs> d in h.GetInvocationList() )
         {
             try
             {
                 d( null, e );
             }
             catch( Exception ex )
             {
                 OnError -= (EventHandler<LowLevelErrorEventArgs>)d;
                 ActivityMonitor.CriticalErrorCollector.Add( ex, "While raising SystemActivityMonitor.OnError event." );
             }
         }
     }
 }