AutomaticUpdaterBackend not working as expected

I have integrated this into my app's "Start Up Form". It does not work as I would expect (so I assume I am doing something wrong).Essentially I first check for updates: AutomaticUpdaterBackend auBackend = new AutomaticUpdaterBackend(); auBackend.Initialize(); // All actions are manual auBackend.UpdateType = UpdateType.OnlyCheck; //Event Handler for updates available auBackend.UpdateAvailable += new EventHandler(auBackend_UpdateAvailable); // Event handler is no updates required auBackend.UpToDate += new SuccessHandler(auBackend_UpToDate); // Event handler for failed check auBackend.CheckingFailed += new FailHandler(auBackend_CheckingFailed); updateStatus = UpdateStatus.checking; // UpdateStatus is an enum If (auBackend.ForceCheckForUpdate()) while(true) { switch (updateStats) {// Everything fine to here, UpdateAvailable envent is triggered, and the UpdateStatus gets changed appropriatly case UpdateStatus.UpdateAvailable: // Upon a dialog and show user what changes are available ans see if they want to proceed if ( Proceed) { auBackend.UpdateType = UpdateType.CheckAndDownload; auBackend.ReadyToBeInstalled += new EventHandler(auBackend_ReadyToBeInstalled); auBackend.ProgressChanged += new UpdateProgressChanged(auBackend_ProgressChanged); auBackend.ForceCheckForUpdate();// At this point, no events are triggered (at least the ones I have handled above) and it loops forever while (!ureadtToInstall) { if (updateStatus != 0) { //Update Progress } } auBackend.InstallNow(); } break;

As the initial call to ForceCheckForUpdate() came back with a UpdateAvailable, I would have thought that the second call (with UpdateType = CheckAndDownload) would eventually trigger the ReadyToBeInstalled event Which is does not.

I also tried setting = new AutomaticUpdaterBackend(); and auBackend.Initialize(); after the proceed if just in case.

Where am I going wrong?

Neal

There are a lot of things wrong with this code. At a glance:

  • ForceCheckForUpdate() doesn't return the result immediately (it's asynchronous). What it *does* return is whether the update checking process began. So this line is meaningless (at least how you're using it):
    If (auBackend.ForceCheckForUpdate())
  • I have no idea what the updateStats bit is all about.
  • You're re-calling ForceCheckforUpdates *again*. Why?

There are other minor bugs, but first fix the major problems.

As the initial call to ForceCheckForUpdate() came back with a UpdateAvailable

Because you called ForceCheckForUpdates() when the UpdateType was CheckOnly.

You're making a Windows Forms app. Don't use the AutomaticUpdaterBackend. Just use our AutomaticUpdater control. It's much easier to use. Especially with UI programs.

Thanks for the prompt reply. Clearly the issue is my lack of understanding.I did try using the Control but also ran into problems (again likely my lack of understanding)I ended up using the wyUpdate.exe with one remaining caveat, I want to launch the application after the update completes, so in wyBuild I set my app.exe to "Execute after Update is Complete". This works however, it leaves the wyUpdate finish screen up waiting for the user to click on Finish. I am not sure if the "Wait for execution to finish before continuing" applies to the app or the wyUpdate.exe. If the later is the case, then it should work. If not, how do I get my App to execute after the user pressed "Finish" in wyUpdate.exe?

Eventually I want to uderstnad the use of the Control and the Backend but for now I need to continue with completing my applications.

Thanks again for your help.

Neal

In File -> Properties -> wyUpdate (in wyBuild) you can tell wyUpdate to close after update completes.