private async void CheckNow_Click(object sender, RoutedEventArgs e) { var checker = new UpdateChecker(); bool updateAvailable; try { updateAvailable = await checker.IsUpdateAvailableAsync(); } catch (UpdateException) { MessageBox.Show("Unable to check for updates", "Error", MessageBoxButton.OK); return; } if (updateAvailable) { var installNowConfirm = MessageBox.Show("New update is available. Download and install now?", "Update available", MessageBoxButton.YesNo); if (installNowConfirm == MessageBoxResult.Yes) { if (!await UpdateInstaller.TryStartInstallerAsync(checker)) { MessageBox.Show("Unable to install updates", "Error", MessageBoxButton.OK); return; } App.CurrentApp.Shutdown(); return; } else { return; } } MessageBox.Show("No updates available", "Update check", MessageBoxButton.OK); }
public static async Task <bool> CheckAndInstallUpdatesAsync() { var checker = new UpdateChecker(); if (await checker.IsUpdateAvailableAsync().ConfigureAwait(false)) { var installNowConfirm = MessageBox.Show("New Start Launcher update is available. Download and install now?", "Update available", MessageBoxButton.YesNo); if (installNowConfirm == MessageBoxResult.Yes) { if (!await UpdateInstaller.TryStartInstallerAsync(checker).ConfigureAwait(false)) { MessageBox.Show("Unable to install updates", "Error", MessageBoxButton.OK); return(false); } return(true); } } return(false); }