Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2. If Downloading Then Exit Sub
  3. Downloading = True
  4.  
  5. Dim wc As New WebClient
  6. AddHandler wc.DownloadProgressChanged, AddressOf wc_ProgressChanged
  7. AddHandler wc.DownloadFileCompleted, AddressOf wc_DownloadDone
  8.  
  9. wc.DownloadFileAsync(New Uri("http://speedtest.ftp.otenet.gr/files/test100Mb.db"), tmp, Stopwatch.StartNew)
  10. End Sub
  11.  
  12. Private Sub wc_DownloadDone(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs)
  13. Downloading = False
  14. End Sub
  15.  
  16. Private Sub wc_ProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs)
  17. Me.Label2.Text = (e.BytesReceived / (DirectCast(e.UserState, Stopwatch).ElapsedMilliseconds / 1000.0#)).ToString("#")
  18. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement