public UpdateHelper(Updater updater, Version currentVersion) { _updater = updater; _currentVersion = currentVersion; _updatesButtonClickAction = CheckForUpdatesAsync; }
public UpdateHelper(Updater updater, Version currentVersion) { _updater = updater; _currentVersion = currentVersion; _updatesButtonClickAction = CheckForUpdatesAsync; }
private void CheckForUpdatesAsync() { // Prevent user from checking for updates while another check is already in progress _updatesButtonClickAction = null; var task = new TaskBuilder() .OnCurrentThread() .BeforeStart(OnBeforeStart) .DoWork(OnDoWork) .Fail(OnFail) .Succeed(OnSucceed) .Build(); task.Start(); }
private void OnSucceed() { if (_updater.IsUpdateAvailable) { if (AllowDownload && AllowInstallUpdate) { _updatesButtonClickAction = InstallUpdateIfAvailable; Logger.Info("Update is ready to install"); Notify(observer => observer.OnUpdateReadyToInstall(_updater.LatestUpdate)); } else { _updatesButtonClickAction = LaunchBrowser; Logger.Info("Update is available"); Notify(observer => observer.OnUpdateReadyToDownload(_updater.LatestUpdate)); } } else { _updatesButtonClickAction = CheckForUpdatesAsync; Logger.Info(string.Format("Application is already up to date")); Notify(observer => observer.OnNoUpdateAvailable()); } }
private void CheckForUpdatesAsync() { // Prevent user from checking for updates while another check is already in progress _updatesButtonClickAction = null; var task = new TaskBuilder() .OnCurrentThread() .BeforeStart(OnBeforeStart) .DoWork(OnDoWork) .Fail(OnFail) .Succeed(OnSucceed) .Build(); task.Start(); }
private void OnSucceed() { if (_updater.IsUpdateAvailable) { if (AllowDownload && AllowInstallUpdate) { _updatesButtonClickAction = InstallUpdateIfAvailable; Logger.Info("Update is ready to install"); Notify(observer => observer.OnUpdateReadyToInstall(_updater.LatestUpdate)); } else { _updatesButtonClickAction = LaunchBrowser; Logger.Info("Update is available"); Notify(observer => observer.OnUpdateReadyToDownload(_updater.LatestUpdate)); } } else { _updatesButtonClickAction = CheckForUpdatesAsync; Logger.Info(string.Format("Application is already up to date")); Notify(observer => observer.OnNoUpdateAvailable()); } }
private void OnFail(ExceptionEventArgs args) { _updatesButtonClickAction = CheckForUpdatesAsync; Logger.Error("Error checking for update", args.Exception); Notify(observer => observer.OnUpdateException(args.Exception)); }
private void OnFail(ExceptionEventArgs args) { _updatesButtonClickAction = CheckForUpdatesAsync; Logger.Error("Error checking for update", args.Exception); Notify(observer => observer.OnUpdateException(args.Exception)); }