コード例 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            DispatcherUnhandledException += (_, args) =>
            {
                MessageBoxUtils.ShowError($"Unhandled exception: `{args.Exception}`");
            };

            Task.Run(() =>
            {
                try
                {
                    int[] appVersion    = UpdateUtils.ConvertVersion(Assembly.GetExecutingAssembly().GetName().Version.ToString(4));
                    int[] latestVersion = UpdateUtils.ConvertVersion(UpdateUtils.GetLatestVersion());

                    for (int i = 0; i < 4; i++)
                    {
                        if (appVersion[i] > latestVersion[i])
                        {
                            break;
                        }
                        if (appVersion[i] == latestVersion[i])
                        {
                            continue;
                        }

                        Process.Start(
                            Path.Combine(ApplicationDataUtils.PathToRootFolder, "updater.exe"),
                            "disable_shortcut"
                            );
                        Environment.Exit(0);
                    }
                }
                catch (Exception ex)
                {
                    CrashUtils.HandleException(ex);
                }
            });

            SetCurrentLanguage();
            new PackStartupWindow().Show();
        }