AUBackend Console Application, can't get it to runSolved

Hi,

I'm trying to create a basic console application which launches the WyUpdate process, and then on completion executes my main application (which has just been updated).

Following the instructions on "http://wyday.com/wybuild/help/silent-update-windows-service.php" gives me no luck at all. The application runs, and executes the "ForceCheckForUpdate" process, but I don't receive any feedback 🙁

I've added a while loop in there just to see if I can't wait for feedback but that doesn't happen.

here is a complete listing of my code.

If anyone has a very basic console app example code available i'd greatly appreciate it. So far i'm very impressed in wyBuild/wyUpdate, but we need to get the AutoUpdater working before my company will use it for future projects.wyBuild makes my life so much easier so I would love some assistance in getting this up and running.

Thanks in advance.

Neville

=============================================using System;using System.Threading;using wyDay.Controls;

namespace NPS.CeAUpdateLauncher{ class Program { private static AutomaticUpdaterBackend auBackend; private static bool receivedFeedback;

static void Main(string[] args) { auBackend = new AutomaticUpdaterBackend { //TODO: set a unique string. // For instance, "appname-companyname" GUID = "CeALauncher_AutoUpdate",

// With UpdateType set to Automatic, you're still in // charge of checking for updates, but the // AutomaticUpdaterBackend continues with the // downloading and extracting automatically. UpdateType = UpdateType.Automatic, };

auBackend.CheckingFailed += auBackend_CheckingFailed; auBackend.UpdateAvailable += auBackend_UpdateAvailable; auBackend.DownloadingFailed += auBackend_DownloadingFailed; auBackend.ExtractingFailed += auBackend_ExtractingFailed; auBackend.ReadyToBeInstalled += auBackend_ReadyToBeInstalled; auBackend.UpdateSuccessful += auBackend_UpdateSuccessful; auBackend.UpdateFailed += auBackend_Failed;

// Initialize() and AppLoaded() must be called after events have been set. // Note: If there's a pending update to be installed, wyUpdate will be // started, then it will talk back and say "ready to install, // you can close now" at which point your app will be closed. auBackend.Initialize(); auBackend.AppLoaded();

if (!auBackend.ClosingForInstall) { //TODO: do your normal service work CheckForUpdates(); }

// while(!receivedFeedback) Thread.Sleep(10000);

}

static void CheckForUpdates() { // Only ForceCheckForUpdate() every N days! // You don't want to recheck for updates on every app start.

if (//(DateTime.Now - auBackend.LastCheckDate).TotalDays > 10 && auBackend.UpdateStepOn == UpdateStepOn.Nothing) { auBackend.ForceCheckForUpdate(); } }

static void auBackend_CheckingFailed(object sender, FailArgs e) { receivedFeedback = true; }

static void auBackend_UpdateAvailable(object sender, EventArgs e) { receivedFeedback = true; }

static void auBackend_DownloadingFailed(object sender, FailArgs e) { receivedFeedback = true; }

static void auBackend_ExtractingFailed(object sender, FailArgs e) { receivedFeedback = true; }

static void auBackend_ReadyToBeInstalled(object sender, EventArgs e) { // ReadyToBeInstalled event is called when // either the UpdateStepOn == UpdateDownloaded or UpdateReadyToInstall

if (auBackend.UpdateStepOn == UpdateStepOn.UpdateReadyToInstall) { //TODO: Delay the installation of the update until // it's appropriate for your app.

//TODO: Do any "spin-down" operations. auBackend.InstallNow() will // exit this process using Environment.Exit(0), so run // cleanup functions now (close threads, close running programs, // release locked files, etc.)

// here we'll just close immediately to install the new version auBackend.InstallNow(); } receivedFeedback = true;

}

static void auBackend_UpdateSuccessful(object sender, SuccessArgs e) { receivedFeedback = true; }

static void auBackend_Failed(object sender, FailArgs e) { receivedFeedback = true; } }}=============================================

Hey Neville,

Instead of using

while (!receivedFeedback)    Thread.Sleep(10000);

Use

static readonly ManualResetEvent resetEvent = new ManualResetEvent(false);


static void Main(string[] args){    //...


    // Blocks until "resetEvent.Set()" on another thread    resetEvent.WaitOne();}

This should fix your problem. Tell me if it helps.

Hi Sam

Thanks for the response. I've implemented the changes you suggested.

The resetEvent.Set() works well with the resetEvent.WaitOne(), and I now receive feedback from the system.

I also found that adding the event handler for UpToDate I was able to receive feedback and exit the program correctly.I am now in the process of adding event handlers for all the events listed in http://wyday.com/wybuild/help/automatic-updates/members.php , and the process seems to be working very well now.

thanks for the assist!

This is truly a fantastic piece of software doing exactly what we one, and giving us the freedom to customise it and mold it where and when we need to.

Thanks again!

My pleasure. If you need any more help, don't hesistate to ask.