Share via

WebClient.UploadProgressChanged Event

OSVBNET 1,401 Reputation points
2022-08-22T14:28:39.017+00:00

Hello,
According to:
https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient.uploadprogresschanged

This event is raised each time an asynchronous upload makes progress, so for UploadValuesAsync and NOT for UploadValues

Is there anyway to get the progress when using UploadValues? I'm already using it inside a thread, beside that am using .NET framework 4.0 and not 4.5.
Thanks for help.

*** even this does not work:

UpClient.UploadValuesAsync(New Uri("http://www.domain.com/bb.php"), FormFields)

Private Sub UpClient_UploadProgressChanged(sender As Object, e As System.Net.UploadProgressChangedEventArgs) Handles UpClient.UploadProgressChanged
ProgressBarX.Value = e.ProgressPercentage

Developer technologies | VB
0 comments No comments

1 answer

Sort by: Most helpful
  1. Michael Taylor 61,226 Reputation points
    2022-08-22T14:47:55.617+00:00

    You cannot get progress notifications from the sync version. They are blocking calls so there would be no way to respond anyway outside a separate thread.

    Not sure what your intended point was around .NET 4 vs .NET 4.5. You can switch to the async version on .NET 4 if you need progress notification.

    As for why your sample code isn't working, we'd need to see the full setup of the webclient. My guess is that you haven't properly hooked up the event or you did so after starting the upload.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.