Beispiel #1
0
        static void Main(string[] args)
        {
            Application.SetCompatibleTextRenderingDefault(false);
            Application.EnableVisualStyles();

            #region Only allow one instance [ML-2448]
            try
            {
                bool firstInstance;
                errorHandlerMutex = new Mutex(false, "Local\\MLifterErrorHandlerMutex", out firstInstance);
                if (!firstInstance)
                {
                    return;
                }
            }
            catch
            { }
            #endregion

            #region Parse command line arguments
            bool fatal = RunningFromStick = false;

            try
            {
                if (args.Length >= 2)
                {
                    fatal            = Convert.ToBoolean(args[0]);
                    RunningFromStick = Convert.ToBoolean(args[1]);
                }
            }
            catch (System.FormatException)
            { }
            #endregion

            //check if there are new error reports to ask the user
            string newErrorReportPath = Path.Combine(AppdataPath, Settings.Default.AppDataFolderErrorReportsNew);
            bool   newFound           = false;
            if (Directory.Exists(newErrorReportPath))
            {
                DirectoryInfo container = new DirectoryInfo(newErrorReportPath);
                foreach (FileInfo report in container.GetFiles())
                {
                    if (report.Extension.ToLowerInvariant() == Resources.ERRORFILE_EXTENSION.ToLowerInvariant())
                    {
                        newFound = true;
                        ErrorHandlerForm errorHandlerForm = new ErrorHandlerForm(fatal, report);
                        Application.Run(errorHandlerForm);
                    }
                }
            }

            //else send old reports
            if (!newFound)
            {
                BusinessLayer.ErrorReportSender.SendPendingReports();
            }

            //wait for the pending threads before exiting main thread (to maintain mutex)
            BusinessLayer.ErrorReportSender.WaitForThreads();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Application.SetCompatibleTextRenderingDefault(false);
            Application.EnableVisualStyles();

            #region Only allow one instance [ML-2448]
            try
            {
                bool firstInstance;
                errorHandlerMutex = new Mutex(false, "Local\\MLifterErrorHandlerMutex", out firstInstance);
                if (!firstInstance)
                    return;
            }
            catch
            { }
            #endregion

            #region Parse command line arguments
            bool fatal = RunningFromStick = false;

            try
            {
                if (args.Length >= 2)
                {
                    fatal = Convert.ToBoolean(args[0]);
                    RunningFromStick = Convert.ToBoolean(args[1]);
                }
            }
            catch (System.FormatException)
            { }
            #endregion

            //check if there are new error reports to ask the user
            string newErrorReportPath = Path.Combine(AppdataPath, Settings.Default.AppDataFolderErrorReportsNew);
            bool newFound = false;
            if (Directory.Exists(newErrorReportPath))
            {
                DirectoryInfo container = new DirectoryInfo(newErrorReportPath);
                foreach (FileInfo report in container.GetFiles())
                {
                    if (report.Extension.ToLowerInvariant() == Resources.ERRORFILE_EXTENSION.ToLowerInvariant())
                    {
                        newFound = true;
                        ErrorHandlerForm errorHandlerForm = new ErrorHandlerForm(fatal, report);
                        Application.Run(errorHandlerForm);
                    }
                }
            }

            //else send old reports
            if (!newFound)
                BusinessLayer.ErrorReportSender.SendPendingReports();

            //wait for the pending threads before exiting main thread (to maintain mutex)
            BusinessLayer.ErrorReportSender.WaitForThreads();
        }