Request New Event for UAB: UpdateNotAvailable

Topics: Updater Application Block
Aug 4, 2003 at 6:00 PM
originally posted by: GDorazio

Currently the UAB has 'balanced' event handlers such as

DownloadStartedCompleted
ManifestValidatedValidationFailed
FilesValidatedValidationFailed

but there is no corresponding 'balanced' event for UpdateAvailable and it appears there may be one needed. To illustrate this need, the ConsoleTest and Flexpoint samples rely on a thread block based on this:

Console.ReadLine();

which of course requires manual intervention. I have deployed a task initiator version of this type of implementation where the console app kicks off the app updater but does not use the manual intervention. It is designed so that it can be a scheduled task. It is at the point where the ReadLine() was made where a wait for event occurs signalling the Update App finishing. For new updates and failed downloads the event handlers exist. But there is no event that indicates completion in the case where there is no update available. Inspection of the code 'DownloadManager.BeginFileDownloads()' reveals this is the case. This causes the task initiator app to wait forever...

Here is proposed code:
1) In Event Registrations of 'ApplicationUpdateManager.SetupDownloadManager()' add this:

dnldMgr.UpdateNotAvailable += new UpdaterActionEventHandler(OnUpdateNotAvailable);

2) In ApplicationUpdateManager add the event:

public event UpdaterActionEventHandler UpdateNotAvailable;
private void OnUpdateNotAvailable(object sender, UpdaterActionEventArgs e )
{
if( null != UpdateNotAvailable )
{
UpdateNotAvailable( this, e );
}
}


3) In DownloaderManager add this event:

internal event UpdaterActionEventHandler UpdateNotAvailable;
private void OnUpdateNotAvailable( )
{
if( null != UpdateNotAvailable )
{
UpdateNotAvailable( this, new UpdaterActionEventArgs( _server, _application.Name ) );
}
}

4) In the 'DownloaderManager.BeginFileDownloads()' add the check:

private void BeginFileDownloads()
{
...
if( isUpdateNeeded )
{
...
}
else
{
...
OnUpdateNotAvailable( );
}
...

5) The final step would be to add ones own event handler to get the event which then allows app shutdown.

Please comment and make suggestions for any shortcomings you see.

Thanks,
Gery