private void WriteHeader(TextWriter writer, string filePath, XRawFileIO reader, string hash, IReadOnlyCollection <int> targetScans)
        {
            var version = ProcessFilesOrDirectoriesBase.GetEntryOrExecutingAssembly().GetName().Version;

            var sb = new StringBuilder();

            sb.AppendLine("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
            sb.AppendLine("<mzXML xmlns=\"http://sashimi.sourceforge.net/schema_revision/mzXML_3.1\"");
            sb.AppendLine(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
            sb.AppendLine(" xsi:schemaLocation=\"http://sashimi.sourceforge.net/schema_revision/mzXML_3.1 http://sashimi.sourceforge.net/schema_revision/mzXML_3.1/mzXML_idx_3.1.xsd\">");
            sb.AppendLine(WriteMsRunTag(reader, targetScans));
            sb.AppendLine(WriteParentFileTag(filePath, hash));
            sb.AppendLine("  <msInstrument>");
            sb.AppendLine("   <msManufacturer category=\"msManufacturer\" value=\"Thermo Finnigan\" />");
            sb.AppendLine("   <msModel category=\"msModel\" value=\"unknown\" />");
            sb.AppendFormat("   <msIonisation category=\"msIonisation\" value=\"{0}\" />", GetIonizationSource(reader)).AppendLine();
            sb.AppendFormat("   <msMassAnalyzer category=\"msMassAnalyzer\" value=\"{0}\" />", GetMzAnalyzer(reader)).AppendLine();
            sb.AppendLine("   <msDetector category=\"msDetector\" value=\"unknown\" />");
            sb.AppendLine("   <software type=\"acquisition\" name=\"Xcalibur\" version=\"3.1.2279\" />");
            sb.AppendLine("  </msInstrument>");
            sb.AppendLine("  <dataProcessing centroided=\"1\">");
            sb.AppendFormat(
                "   <software type=\"conversion\" name=\"WriteFaimsXMLFromRawFile\" version=\"{0}\" />", version).AppendLine();
            sb.Append("  </dataProcessing>");

            var headerText = sb.ToString();

            ByteTracker(headerText);

            writer.WriteLine(headerText);
        }
        /// <summary>
        /// Entry method
        /// </summary>
        private static void Main()
        {
            try
            {
                mLogger = new FileLogger(@"Logs\StatusMsgDBUpdater", BaseLogger.LogLevels.INFO);

                var appVersion = ProcessFilesOrDirectoriesBase.GetEntryOrExecutingAssembly().GetName().Version.ToString();
                mLogger.Info("=== Started StatusMessageDBUpdater V" + appVersion + " =====");

                var restart         = true;
                var runFailureCount = 0;
                var startTime       = DateTime.UtcNow;

                while (restart)
                {
                    // Start the main program running
                    try
                    {
                        var mainProcess = new MainProgram();
                        mainProcess.DebugEvent   += MainProcess_DebugEvent;
                        mainProcess.ErrorEvent   += MainProcess_ErrorEvent;
                        mainProcess.WarningEvent += MainProcess_WarningEvent;
                        mainProcess.StatusEvent  += MainProcess_StatusEvent;

                        if (!mainProcess.InitMgr(startTime))
                        {
                            ProgRunner.SleepMilliseconds(1500);
                            return;
                        }

                        // Start the main process
                        // If it receives the ReadConfig command, DoProcess will return true
                        restart         = mainProcess.DoProcess();
                        runFailureCount = 0;
                    }
                    catch (Exception ex2)
                    {
                        ShowErrorMessage("Error running the main process", ex2);
                        runFailureCount++;
                        var sleepSeconds = 1.5 * runFailureCount;
                        if (sleepSeconds > 30)
                        {
                            sleepSeconds = 30;
                        }
                        ProgRunner.SleepMilliseconds((int)(sleepSeconds * 1000));
                    }
                }

                FileLogger.FlushPendingMessages();
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error starting application", ex);
            }

            ProgRunner.SleepMilliseconds(1500);
        }