I am having a problem with timeouts in my DownloadFileAsync function. I am using VB.NET. According to multiple sources the "DownloadFileCompleted" event should be raised when the connection to the server while downloading is lost and the error flag should be set. Nothing of this is happening. I am trying this through starting the download and then simply stopping my internet connection through disabling WLAN.
Private Sub DownloadMod_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles DownloadMod.DownloadFileCompleted
MsgBox("Test1")
If e.Error IsNot Nothing Then
MsgBox("Test2")
End If
End Sub
Neither the test1 nor the test2 message box is appearing after loosing connection. I read that the standard timeout is 100 s, so I always waited 2 minutes to make sure, but nothing is happening.
This is how I start the download:
DownloadMod.DownloadFileAsync(New System.Uri("http://linktothefile.com/downloadfile.txt"), System.AppDomain.CurrentDomain.BaseDirectory & "Downloads\downloadfile.txt", Stopwatch.StartNew)
The stopwatch is in there for calculation of the download speed.
Downloadmod is defined like this:
Private WithEvents DownloadMod As New Net.WebClient
I would appreciate if someone could help me with this problem.
Turin