Two questions

Topics: Updater Application Block
Aug 17, 2005 at 7:48 AM
originally posted by: lottoman2000

Hello everyone,

I have two questions regarding the UAB and I would really appreciate it if someone can answer any of them.

1) Can I resume a partially downloaded file using the UAB?
2) Is it possible to know the total size of the files to be downloaded before UAB starts downloading the files? (lets say when updates are found)

Thanks in advance.
Aug 18, 2005 at 5:40 PM
originally posted by: ErickGDelC

Yes to both questions =)

there is a CheckForResumeAndProceed method in bitsdownloader, and you can subscribe to downloadProgress event and check for Microsoft.ApplicationBlocks.Updater.DownloadProgressEventArgs, it has properties for BytesTransferred, BytesTotal, FilesTransferred and FilesTotal among others...
Aug 19, 2005 at 10:12 AM
originally posted by: lottoman2000

Thanks for your reply.

Sorry my questions were not clear from the beginning.

Regarding the first question, I wanted to know if the download will resume in this scenario:
1) Check for updates, updates are found, updates download started.
2) User closes the application in the middle of downloading a file.
3) User opens the application, Check for update:

Will Bitsdownloader resume downloading the file or start downloading the file all over again? for me it starts all over again.
Regarding the Second question, I wanted to know total size before downloading in case the program has multipule manifests. If I am to use only the download progress method, I can only know the bytes total for the current manifest. Is that correct?

Oct 7, 2005 at 12:01 AM
originally posted by: puy0

About resuming, i've got the same problem... And i've found what's happening.

As shown in Quickstarts, when user close application we're aborting the thread.

In BitsDownloader.Download() there is :
catch( Exception e )
// if exception, clean up job
OnJobError( task, backgroundCopyJob, null, e );

Since a ThreadAbortException is raised, job is cancelled because of OnJobError :

So even if using PendingUpdatesDetected && updater.ResumePendingUpdates(); job is deleted in BITS and then will restart!

I have corrected BitsDownloader to manage this case since i've found no way to stop thread without confusing bitsdownloader :
state != BGJOBSTATE.BGJOBSTATE_TRANSFERRING && // don't interrupt downloads in progress
state != BGJOBSTATE.BGJOBSTATE_TRANSFERRED && // don't cancel a finished download
state != BGJOBSTATE.BGJOBSTATETRANSIENTERROR && // don't cancel when connection problems
state != BGJOBSTATE.BGJOBSTATE_ERROR ) // don't cancel when connection problems

I hope this will work!

Good luck, Have fun.