Ejemplo n.º 1
0
 internal static Task SelfUpdate(IViewModelServiceProvider services, NugetStore store)
 {
     return(Task.Run(async() =>
     {
         var dispatcher = services.Get <IDispatcherService>();
         try
         {
             await UpdateLauncherFiles(dispatcher, services.Get <IDialogService>(), store, CancellationToken.None);
         }
         catch (Exception e)
         {
             dispatcher.Invoke(() => selfUpdateWindow?.ForceClose());
             throw;
         }
     }));
 }
Ejemplo n.º 2
0
        internal static async Task DownloadAndInstallNewVersion(IDispatcherService dispatcher, IDialogService dialogService, string strideInstallerUrl)
        {
            try
            {
                // Diplay progress window
                var mainWindow = dispatcher.Invoke(() => Application.Current.MainWindow as LauncherWindow);
                dispatcher.InvokeAsync(() =>
                {
                    selfUpdateWindow = new SelfUpdateWindow {
                        Owner = mainWindow
                    };
                    selfUpdateWindow.LockWindow();
                    selfUpdateWindow.ShowDialog();
                }).Forget();


                var strideInstaller = Path.Combine(Path.GetTempPath(), $"StrideSetup-{Guid.NewGuid()}.exe");
                using (WebClient webClient = new WebClient())
                {
                    webClient.DownloadFile(strideInstallerUrl, strideInstaller);
                }

                var startInfo = new ProcessStartInfo(strideInstaller)
                {
                    UseShellExecute = true
                };
                // Release the mutex before starting the new process
                Launcher.Mutex.Dispose();

                Process.Start(startInfo);

                Environment.Exit(0);
            }
            catch (Exception e)
            {
                await dispatcher.InvokeAsync(() =>
                {
                    if (selfUpdateWindow != null)
                    {
                        selfUpdateWindow.ForceClose();
                    }
                });

                await dialogService.MessageBox(string.Format(Strings.NewVersionDownloadError, e.Message), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 3
0
 internal static Task SelfUpdate(IViewModelServiceProvider services, NugetStore store)
 {
     return(Task.Run(async() =>
     {
         var dispatcher = services.Get <IDispatcherService>();
         try
         {
             await UpdateLauncherFiles(dispatcher, store, CancellationToken.None);
         }
         catch (Exception e)
         {
             dispatcher.Invoke(() => selfUpdateWindow?.ForceClose());
             string message = $"An error occurred while updating the launcher. If the problem persists, please reinstall this application.{Environment.NewLine}{Environment.NewLine}Details:{Environment.NewLine}{e}";
             await services.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
             // We do not want our users to use the old launcher when a new one is available.
             Environment.Exit(1);
         }
     }));
 }