Hello,
This seems like a simple question, but I've been struggling with it for awhile now.
I'm writing something to download about 200 small (Around 200kb) files at a time. I pass the file urls off to a class which starts the downloads. The problem is that it'll start the download (Just creates a 0kb file) and then slowly downloads each file one by one, waiting for the next to complete despite this being a threaded class. This would be fine but after about a minute, windows removes all of the 0kb files and I'm stuck with only a few of the files being downloaded. Any ideas how to get multiple files to be downloaded concurrently?
This seems like a simple question, but I've been struggling with it for awhile now.
I'm writing something to download about 200 small (Around 200kb) files at a time. I pass the file urls off to a class which starts the downloads. The problem is that it'll start the download (Just creates a 0kb file) and then slowly downloads each file one by one, waiting for the next to complete despite this being a threaded class. This would be fine but after about a minute, windows removes all of the 0kb files and I'm stuck with only a few of the files being downloaded. Any ideas how to get multiple files to be downloaded concurrently?
VB.NET:
Imports System.Net
Imports System.IO
Public Class DownloadClass
Public downloadUrl As String
Public folderURL As String
Public Name As String
Private InstancedThread As System.Threading.Thread
Public Sub DownloadFile(ByVal strsource As String, ByVal folder As String, ByVal name As String)
'Try
Dim webClient As System.Net.WebClient = New System.Net.WebClient()
webClient.DownloadFile(strsource, folder & "\" & name)
'Catch ex As Exception
' 'Nothing here.
'End Try
End Sub
Public Sub Kickit()
InstancedThread = New System.Threading.Thread(AddressOf startRunning)
InstancedThread.Start()
End Sub
Private Sub startRunning()
DownloadFile(downloadUrl, folderURL, Name)
End Sub
End Class