views:

219

answers:

1

Hello everyone,

I am using VSTS 2008 + C# + .Net 3.5 to develop a console application to upload a file to server. For the WebClient.UploadProgressChanged Event, I am wondering what is the rule when this event will be raised? I read the below document but find no accurate information (like will be raised 10 times during upload or something). Does anyone know what is the rule when this event will be raised?

http://msdn.microsoft.com/en-us/library/system.net.webclient.uploadprogresschanged.aspx

thanks in advance, George

+1  A: 

No, I don't think there is any specific rule. How many times event is called is mostly dependent on how large is the file you are uploading and how fast is your connection.

grega g
Thanks, can I understand the event will be raised randomly -- i.e. even if I use the same client upload the same file to the same server, the times of event raised may be different?
George2
Yes. Msdn says 'This event is raised each time an asynchronous upload makes progress.' so for small files it might very well be similar almost every time, but you must assume its random at all time (ie. don't base any logic on how many times it will be raised).
grega g
If I am rely on the event to implement a progress bar, do you think it should be fine? I do not want the event to be raised too few times (0% and 100%), and I also do not wnat the event to be raised too often (e.g. raise each time 0.1% of the whole file is uploaded). Any comments?
George2