I have to call Install() twice

I am using the AutomaticUpdaterBackend to build the features I need. I need to be able to:

1) check for update 2) if update exists choose to install it or not.3) If choose to install then install / if not do nothing, now and next start up.

I am using UpdateType.CheckAndDownload and when I call ForceCheckForUpdate() it will let me know if there is an update. When there is an update my Install button will show, that will call InstallNow(). When I click Install the first time nothing happens. The second time I click it, it closes the app and installs the update.

Why do I need to click it twice? What are the steps I should take to make it work for my requirements?

Also it seams that when I check for updates the automatic behavior is that on next start up it will auto install them. How do I stop this? Unless the user specifically clicks install I do not want the updates to install on next start up.

Thank you in advance for your help

I have included my class below if you would like a reference on how I am using it, and if someone else would like to see how I am using it if it will help them out.

public class UpdateUtilities : ViewModel<UpdateUtilities>, IDisposable {

#region Fields

private AutomaticUpdaterBackend _automaticUpdaterBackend; private UpdateStatus _updateStatus = UpdateStatus.Unknown; private readonly ManualResetEvent _receivedStuff = new ManualResetEvent(false); private string _statusMessage;

#endregion

#region Constructor

/// <summary> /// Initializes a new instance of the <see cref="UpdateUtilities"/> class. /// </summary> /// <param name="updateType">Type of the update.</param> public UpdateUtilities(UpdateType updateType) { Initialize(updateType); }

#endregion

#region Initialize

private void Initialize(UpdateType updateType) {

_automaticUpdaterBackend = new AutomaticUpdaterBackend { GUID = "{Product-Company}",

UpdateType = updateType, };

_automaticUpdaterBackend.BeforeChecking += HandleBeforeChecking; _automaticUpdaterBackend.BeforeDownloading += HandleBeforeDownloading; _automaticUpdaterBackend.BeforeExtracting += HandleBeforeExtracting; _automaticUpdaterBackend.BeforeInstalling += HandleBeforeInstalling; _automaticUpdaterBackend.Cancelled += HandleCanceled; _automaticUpdaterBackend.CheckingFailed += HandleCheckingFailed; _automaticUpdaterBackend.ClosingAborted += HandleClosingAborted; _automaticUpdaterBackend.DownloadingFailed += HandleDownloadingFailed; _automaticUpdaterBackend.DownloadingFailed += HandleDownloadingFailed; _automaticUpdaterBackend.ExtractingFailed += HandleExtractingFailed; _automaticUpdaterBackend.ProgressChanged += HandleProgressChanged; _automaticUpdaterBackend.ReadyToBeInstalled += HandleReadyToBeInstalled; _automaticUpdaterBackend.UpdateAvailable += HandleUpdateAvailable; _automaticUpdaterBackend.UpdateFailed += HandleUpdateFailed; _automaticUpdaterBackend.UpdateStepMismatch += HandleUpdateStepMismatch; _automaticUpdaterBackend.UpdateSuccessful += HandleUpdateSuccessful; _automaticUpdaterBackend.UpToDate += HandleUpToDate;

_automaticUpdaterBackend.Initialize(); _automaticUpdaterBackend.AppLoaded(); }

#endregion

#region Public Methods

/// <summary> /// Checks for updates. /// </summary> public void CheckForUpdates() { _receivedStuff.Set(); if (_automaticUpdaterBackend.AreChangesRTF) { StatusMessage = "Ready to be installed";

UpdateStatus = UpdateStatus.UpdateAvailable; OnPropertyChanged(i => i.UpdateReadyToInstall); _receivedStuff.Set(); } else { _automaticUpdaterBackend.ForceCheckForUpdate(); } }

/// <summary> /// Starts the update. /// </summary> public void Update() { UpdateStatus = UpdateStatus.Installing; StatusMessage = "Installing.."; _receivedStuff.Set(); _automaticUpdaterBackend.InstallNow(); }

#endregion

#region Events

/// <summary> /// Handles the update successful event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleUpdateSuccessful(object sender, SuccessArgs e) { StatusMessage = string.Format("Update Successful: {0}", e); _receivedStuff.Set(); }

/// <summary> /// Handles the update step mismatch event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected virtual void HandleUpdateStepMismatch(object sender, EventArgs e) { StatusMessage = "Update Step Mismatch"; _receivedStuff.Set(); }

/// <summary> /// Handles the update failed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleUpdateFailed(object sender, FailArgs e) { StatusMessage = string.Format("Update Failed: {0}", e); _receivedStuff.Set(); }

/// <summary> /// Handles the ready to be installed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected virtual void HandleReadyToBeInstalled(object sender, EventArgs e) { StatusMessage = "Ready to be installed";

UpdateStatus = UpdateStatus.UpdateAvailable; OnPropertyChanged(i => i.UpdateReadyToInstall); _receivedStuff.Set(); }

/// <summary> /// Handles the progress changed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="progress">The progress.</param> protected virtual void HandleProgressChanged(object sender, int progress) { StatusMessage = string.Format("Downloading update: {0}%", progress); _receivedStuff.Set(); }

/// <summary> /// Handles the extracting failed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleExtractingFailed(object sender, FailArgs e) { StatusMessage = "Extracting Failed"; _receivedStuff.Set(); }

/// <summary> /// Handles the closing aborted event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected virtual void HandleClosingAborted(object sender, EventArgs e) { }

/// <summary> /// Handles the canceled event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected virtual void HandleCanceled(object sender, EventArgs e) { }

/// <summary> /// Handles the before installing event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleBeforeInstalling(object sender, BeforeArgs e) { }

/// <summary> /// Handles the before extracting event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleBeforeExtracting(object sender, BeforeArgs e) { StatusMessage = "Extracting Files"; _receivedStuff.Set(); }

/// <summary> /// Handles the before downloading event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleBeforeDownloading(object sender, BeforeArgs e) { }

/// <summary> /// Handles the before checking event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleBeforeChecking(object sender, BeforeArgs e) { StatusMessage = "Checking for updates.."; _receivedStuff.Set(); }

/// <summary> /// Handles up to date event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleUpToDate(object sender, SuccessArgs e) { StatusMessage = "Software is up to date"; _receivedStuff.Set(); }

/// <summary> /// Handles the update available event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected virtual void HandleUpdateAvailable(object sender, EventArgs e) { StatusMessage = "Software update is available"; _receivedStuff.Set(); }

/// <summary> /// Handles the downloading failed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleDownloadingFailed(object sender, FailArgs e) { StatusMessage = string.Format("Downloading Update failed. : {0}", e); _receivedStuff.Set(); }

/// <summary> /// Handles the checking failed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected virtual void HandleCheckingFailed(object sender, FailArgs e) { StatusMessage = string.Format("Checking for Update failed. : {0}",e); _receivedStuff.Set(); }

#endregion

#region Properties

/// <summary> /// Gets a value indicating whether [update ready to install]. /// </summary> public bool UpdateReadyToInstall { get { return UpdateStatus == UpdateStatus.UpdateAvailable; } }

/// <summary> /// Gets or sets the status message. /// </summary> public string StatusMessage { get { return _statusMessage; } set { if (_statusMessage != value) { _statusMessage = value; OnPropertyChanged(i => i.StatusMessage); OnPropertyChanged(i => i.UpdateReadyToInstall); } } }

/// <summary> /// Gets the update status. /// </summary> public UpdateStatus UpdateStatus { get { return _updateStatus; } set { _updateStatus = value; OnPropertyChanged(i => i.UpdateStatus); OnPropertyChanged(i => i.UpdateReadyToInstall); } }

#endregion

#region Implementation of IDisposable

/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { _receivedStuff.Dispose(); _automaticUpdaterBackend.Dispose(); }

#endregion }

Hey Scott,

The first time you click install it gets your app to the point where all the updates are extracted & patches and ready to actually be installed. The seconds Install() shuts down your app and starts the process. Handle all the AutomaticUpdaterBackend events and you'll see why this happens.

If you want things to be automatic then set the UpdateType to Automatic.