Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Backgroundworker and progress
#9
Well in that case you dont need a background worker to display the download progress because WebClient object has it's own set of event handlers just declare the web client under the main class of your project

Example:
[code2=vbnet]Public Class Form1
Dim WithEvents WC As New WebClient[/code2]

Then start the download :

[code2=vbnet]Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
WC.DownloadFileAsync("Address", "FileName")
End Sub[/code2]

Increment the progressbar acording to the download percentage:

[code2=vbnet]Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub[/code2]

This is the most simple way of downloadng a file and showing progress in a progressbar. You can also use a background worker but that will only complicate things

NOTE : Leave the progressbar at it's default value of 100 because e.ProgressPercentage should be a integer no larger than 100
Sssssssssoftware developer...


Messages In This Thread
Backgroundworker and progress - by brco900033 - 01-26-2013, 09:30 AM
Re: Backgroundworker and progress - by Snake_eyes - 01-26-2013, 11:29 AM
Re: Backgroundworker and progress - by Snake_eyes - 01-27-2013, 07:55 AM
Re: Backgroundworker and progress - by brco900033 - 02-01-2013, 12:26 PM
Re: Backgroundworker and progress - by Snake_eyes - 02-08-2013, 03:41 AM
Re: Backgroundworker and progress - by brco900033 - 02-15-2013, 06:18 AM
Re: Backgroundworker and progress - by Snake_eyes - 02-15-2013, 01:20 PM
Re: Backgroundworker and progress - by brco900033 - 02-21-2013, 11:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Modding the Progress Bar zmanalpha 4 18,006 09-26-2012, 01:25 PM
Last Post: zmanalpha

Forum Jump:


Users browsing this thread: 1 Guest(s)