WebClient.UploadFileAsync -- Events Not Being Raised

  • Thread starter Thread starter Frank L. Smith
  • Start date Start date
F

Frank L. Smith

Guest
Hi folks,

Im in the process of building a class. In that class, Im using a WebClient to upload files asynchronously:


Private Sub Upload()
Using client As New WebClient
client.Credentials = New NetworkCredential(UserName, Password)
AddHandler client.UploadProgressChanged, AddressOf wc_UploadProgressChanged
AddHandler client.UploadFileCompleted, AddressOf wc_UploadFileCompleted

For i As Integer = 0 To FileListToUpload.Count - 1
If client.IsBusy Then
Threading.Thread.Sleep(1000)
i -= 1
Else
Dim thisUri As New Uri(ServerName & GetFileName(FileListToUpload(i)))
client.UploadFileAsync(thisUri, FileListToUpload(i))
End If
Next
End Using
End Sub

Private Sub wc_UploadProgressChanged(ByVal sender As Object, _
ByVal e As System.Net.UploadProgressChangedEventArgs)

Stop

End Sub

Private Sub wc_UploadFileCompleted(ByVal sender As Object, _
ByVal e As System.Net.UploadFileCompletedEventArgs)

Stop

End Sub





Thats working - it is in fact uploading the files, but its not raising the events.

Im wondering if anyone spots something that Ive done wrong?


Thanks! :)


Please call me Frank :)

Continue reading...
 
Back
Top