private static void ShowMessageOutOfDateVersion(DefaultEventArgs eventArgs) { WpfPitchTuner.Business.ServiceUpdater.VersionInfo lastVersionInfo = (WpfPitchTuner.Business.ServiceUpdater.VersionInfo)eventArgs.ObjArg; MessageBoxResult result = MessageBox.Show(String.Format("A new version ({0}) is available, do you want to go to the homepage?", lastVersionInfo.LatestVersion), "New Version", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { Process.Start(lastVersionInfo.LatestVersionUrl); } }
void CheckForApplicationUpdates() { WebProxy proxy = null; if (enableProxy) { proxy = new WebProxy(host, port); proxy.Credentials = new NetworkCredential(proxyUser, proxyPassword, proxyDomain); } ServiceUpdater updater = new ServiceUpdater(proxy); Task.Factory.StartNew(() => { WpfPitchTuner.Business.ServiceUpdater.VersionInfo version = null; try { version = updater.CheckForUpdates(UpdateUri); } catch (Exception) { } return(version); }).ContinueWith(o => { WpfPitchTuner.Business.ServiceUpdater.VersionInfo lastVersionInfo = (WpfPitchTuner.Business.ServiceUpdater.VersionInfo)o.Result; if (lastVersionInfo != null) { Version productVersion = Utility.GetProductVersion(); bool isVersionUpToDate = lastVersionInfo.LatestVersion <= productVersion; RaiseEventInvoker(isVersionUpToDate ? SoftwareUpToDateEvent : SoftwareOutOfDateEvent, new DefaultEventArgs { ObjArg = lastVersionInfo }); } else { RaiseEventInvoker(NetworkErrorEvent); } }); }