Download error event

Topics: Updater Application Block
Sep 9, 2004 at 1:58 PM
originally posted by: Porc

I need a to know when a download error has occured, otherwise the UAB just keeps attempting to download forever in a background thread does it not ?

I have seen some discussion about this but as the message board is undergoing some maintainance I could'nt find much info.

Before I get into it if there is someone who has been down this road before, willing to share some tips I would be grateful.

Thanks.
Sep 10, 2004 at 5:32 AM
originally posted by: Porc

I sorted it methinks ( also has no update available event ):

For those who don't know heres what you do :

To DownloadManager.cs

add two events in the 'Event Definitions' region :

<pre>internal event UpdaterActionEventHandler NoUpdateAvailable;
private void OnNoUpdateAvailable( )
{
if( null != NoUpdateAvailable )
{
NoUpdateAvailable( this, new UpdaterActionEventArgs( _server, _application.Name ) );
}
}

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

</pre>

then in the CheckDownloadCompleteOrError Method

add

<pre>
case JobStatus.Error:
{
_dnldJob.Status = JobStatus.Error;
OnDownloadError();
break;
}
</pre>

and to the BeginFileDownloads() method add

<pre>
OnNoUpdateAvailable();
</pre>

in the 'else' part

..........................................................................

ApplicationUpdater.cs

..........................................................................

add events to the event region

<pre>
public event UpdaterActionEventHandler DownloadError;
private void OnDownloadError(object sender, UpdaterActionEventArgs e)
{
if( null != DownloadError )
{
DownloadError( this, e );
}
}

public event UpdaterActionEventHandler NoUpdateAvailable;
private void OnNoUpdateAvailable( object sender, UpdaterActionEventArgs e )
{
if( null != UpdateAvailable )
{
NoUpdateAvailable( this, e );
}
}
</pre>

add handlers to the download manager events

<pre>

dnldMgr.DownloadError +=new UpdaterActionEventHandler(OnDownloadError);

dnldMgr.NoUpdateAvailable += new UpdaterActionEventHandler( OnNoUpdateAvailable );

</pre>

sorted.