private async Task CheckForUpdates() { PackageUpdateAvailabilityResult update = await _currentPackage.CheckUpdateAvailabilityAsync(); if (update.Availability == PackageUpdateAvailability.Available || update.Availability == PackageUpdateAvailability.Required) { DialogResult result = MessageBox.Show("There's a new update available! Your application will be automatically closed in order to install it.", "Update Available", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { Application.Exit(); Application.ExitThread(); } } else if (update.Availability == PackageUpdateAvailability.NoUpdates) { MessageBox.Show("No updates are available."); } else if (update.Availability == PackageUpdateAvailability.Error) { MessageBox.Show("Update checked reported an error."); } else if (update.Availability == PackageUpdateAvailability.Unknown) { MessageBox.Show("Unknown Update state."); } else { MessageBox.Show("The CheckUpdateAvailabilityAsync() method did not return an expected value."); } }
private void RadButton_Click(object sender, RoutedEventArgs e) { // 1. check for update // todo - Having trouble with GetAwaiter, switched to synchronous GetResults instead PackageUpdateAvailabilityResult result = Package.Current.CheckUpdateAvailabilityAsync().GetResults(); switch (result.Availability) { case PackageUpdateAvailability.Available: case PackageUpdateAvailability.Required: var popupResult = MessageBox.Show("an update is available, do you want to apply it now?"); if (popupResult == MessageBoxResult.Yes) { InstallUpdate(); } break; case PackageUpdateAvailability.NoUpdates: MessageBox.Show("You are running the latest version."); break; case PackageUpdateAvailability.Unknown: MessageBox.Show("It is unknown if there is an update available."); break; default: break; } }