Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WebClient.DownloadFileAsync Cancel not working
Message
De
11/03/2008 09:47:05
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01300799
Message ID:
01300841
Vues:
14
That would be nice, but the client is scoped to the local procedure.

Glenn

>>We have developed a WebForm to allow users to download updates from our website. So far the download process is going well. We do have a problem with WebClient.Cancel however. When issued we never receive an event at our handler (DownloadFileComplete) and to make matters worse the download continues until the file is completely processed.
>>
>>
>>  Public Sub GetFile(ByVal fName As String, ByVal ftpPath As String, ByVal locPath As String)
>>        Dim client As New WebClient
>>        AddHandler client.DownloadFileCompleted, AddressOf DownloadFileComplete
>>        '  Specify a progress notification handler.
>>        AddHandler client.DownloadProgressChanged, AddressOf DownloadProgress
>>        Try
>>            client.Credentials = New NetworkCredential("upgrades", "jamboree8035")
>>
>>            client.DownloadFileAsync(UriPath, locPath)
>>        Finally
>>            'Response.Redirect("default.aspx")
>>        End Try
>>    End Sub
>>
>>   Public Sub DownloadFileComplete(ByVal sender As Object, ByVal e As DownloadDataCompletedEventArgs)
>>        Response.Redirect("~/default.aspx")
>>    End Sub
>>
>>    Sub DownloadProgress(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
>>        Me.Label1.Text = e.ProgressPercentage.ToString
>>    End Sub
>>
>>    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
>>        Dim client As New WebClient
>>        client.CancelAsync()
>>        client.Dispose()
>>    End Sub
>>
>>
>>Any ideas?
>>
>>Thanks
>
>I'm sorry if this is a wrong question, but why do you define dim client as new WebClient again in your btnCancel code? Should it use already defined client instead?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform