J'ai le plus gros problème pour contourner un bug, et j'espère pouvoir obtenir quelques conseils sur ce site. En bref, j'essaie de faire un appel de service Web asynchrone à partir de mon application VB.NET. Mais mon callback "client_DownloadDataCompleted" n'est JAMAIS appelé lorsque le téléchargement est terminé.VB.NET DownloadDataAsync:
Voici mon code complet:
Public Sub BeginAsyncDownload(ByVal Url As String)
Dim waiter As System.Threading.AutoResetEvent = New System.Threading.AutoResetEvent(False)
Dim client As WebClient = New WebClient()
'client_DownloadDataCompleted method gets called when the download completes.
AddHandler client.DownloadDataCompleted, AddressOf client_DownloadDataCompleted
Dim uri As Uri = New Uri(Url)
Downloading = True 'Class variable defined elsewhere
client.DownloadDataAsync(uri, waiter)
End Sub
Private Sub client_DownloadDataCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs)
MessageBox.Show("Download Completed")
Downloading = False
Debug.Print("Downloaded")
End Sub
Encore une fois, la méthode client_DownloadDataCompleted est jamais appelé. J'ai également essayé d'employer la méthode:
Private Sub client_DownloadDataCompleted(ByVal sender As Object, ByVal e As DownloadDataCompletedEventArgs)
Sans la chance. Ce dont j'ai vraiment besoin, c'est que la variable "Téléchargement" soit désactivée lorsque le téléchargement est terminé.
Merci d'avance! Brett