Beispiel #1
0
        static void Main()
        {
            Stopwatch sw = Stopwatch.StartNew();

            //If debuging and launched from other place (Bootstrap), launch debugger
            if (Environment.GetCommandLineArgs().Contains("/debug") && !Debugger.IsAttached)
            {
                Debugger.Launch();
            }
            sw.TaskEnd("dbgchk");
            //Various init stuff (that mostly "can" be removed as they serve
            //debugging more than function


            //Needs to be called before Log is setup, as it moves where log might be.
            FixCwd();


            sw.TaskEnd("fixcwd");
            //Log exceptions that is caught. Wanting to know about this cause of performance
            AppDomain.CurrentDomain.FirstChanceException += Log.FirstChanceException;
            AppDomain.CurrentDomain.FirstChanceException += heatmap.OnException;


            sw.TaskEnd("appdomain 2");

            string info =
                $"Application Chummer5a build {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version} started at {DateTime.UtcNow} with command line arguments {Environment.CommandLine}";

            sw.TaskEnd("infogen");

            Log.Info(info);

            sw.TaskEnd("infoprnt");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            sw.TaskEnd("languagefreestartup");
            LanguageManager.Instance.Load(GlobalOptions.Instance.Language, null);
            // Make sure the default language has been loaded before attempting to open the Main Form.

            sw.TaskEnd("Startup");
            if (LanguageManager.Instance.Loaded)
            {
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.ThreadException += ApplicationOnThreadException;

                frmMain main = new frmMain();

                try
                {
                    Application.Run(main);
                }
                catch (Exception ex)
                {
                    main.Hide();
                    main.ShowInTaskbar = false;
                    CrashHandler.WebMiniDumpHandler(ex);
                }
            }
            else
            {
                Application.Exit();
            }

            string ExceptionMap = heatmap.GenerateInfo();

            Log.Info(ExceptionMap);
        }