tags:

views:

255

answers:

3

Hi,

I am coding a system which has a small FTP module included inside, it's not the main feature at all, but needed...

I must link the progressbar with the WebClient class event DownloadProgressChangedEventHandler and AsyncCompletedEventHandler, the progressbar increment is ok, and the ASyncCompletedEventHandler launch a MessageBox (as intended), the problem is that the progress bar see to load too slow...

problem :

My MessageBox pop at 100% (launched by the event handler), BUT when the MessageBox pop my progress bar is only at +-80% (but the .VALUE is really 100), the first though I had was that they have added a "smooth" effect in Windows Vista which slow down the progressbar relatively to it's true value.

If any of you have experienced the same problem thanks for your help.

A: 

Before you display your message box, call Application.DoEvents() to force all the pending Windows queued messages to be processed. Your progress bar is probably not getting a chance to paint itself one last time before the message box displays.

mjmarsh
The progress bar should process messages while the dialog is visible too.
SLaks
I can't post image because I don't have enought reputation here, but the bar is not 1-2tick away, it's 20% away (20% being about 2second delay). I did a test with Application.DoEvents() and it doesn't look like it changed anything, it's still arround 80-85% (visually), and the value is 100.
Dominique
A: 

Why not simply set the progress bar value to 100% on the same DownloadProgressChangedEventHandler event handler that displays the message box?

Paul Sasik
hehe, I tried that too, as previously said I think it might be caused because they made in go "smooth" i.e if it goes from 0 to 100 it will do it slowly like 100% increase splitted over 1 second instead of "instant 100%".It might has something to do with Windows Vista, I'll try on a XP pc soon to see if the same "smoothing" effect happen.
Dominique
+1  A: 

For those of you who want to know, Vista actually add a "smoothing" to the loadingbar change, it look like the "Tweening effect" of Flash.

I tried on Windows XP and the bar reach 100% exactly when the value reach 100. On Vista it look like they have decided that the "loading" would be splitted over a delay X.

Dominique