Backgroundworker show progress

M

mcw.willart

Hi,

I use a backgroundworker to get the total size of a homeshare (as it
is a bit time-consuming). Wat i would like to do, is show the
progress, but at start i don't know how much files/folders will come
up, so i dont't know how to feed the progressbar (i believe i need to
know the maximum # of files to get a representative progress bar?).

Anyone has any ideas?

Kind regards,

Mario
The Netherlands
 
P

Peter Duniho

I use a backgroundworker to get the total size of a homeshare (as it
is a bit time-consuming). Wat i would like to do, is show the
progress, but at start i don't know how much files/folders will come
up, so i dont't know how to feed the progressbar (i believe i need to
know the maximum # of files to get a representative progress bar?).

To show the user an accurate percentage completion, you need to know the
total amount of work. There's no way around that.

I don't know what it means to "get the total size of a homeshare" (what's
a "homeshare"?), but if that involves traversing a directory structure and
adding up file sizes or something like that, then yes...you can't
accurately determine the total amount of work without doing the whole
traversal. At which point you could have simply finished the work already.

That said, you can do some things to "fake it". One is to abandon the
idea of showing progress per se. Just show some indication of activity so
that the user knows you're doing _something_. Another option is to do a
quick preliminary traversal, enumerating the first one or two directory
levels, and then base your progress on that. The relative progress could
still wind up skewed if there is a huge difference in the work for each
directory near the top level, but it's about the best you can do in this
situation. In most cases, it would provide pretty good feedback to the
user.

Pete
 
M

mcw.willart

That said, you can do some things to "fake it". One is to abandon the
idea of showingprogressper se. Just show some indication of activity so
that the user knows you're doing _something_.

Pete, thanks for your response. I decided to show an animated gif of a
progressbar during the time the backgroundworker is active, so users
will see some activity.

Greetings,

Mario
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top