Public Class Form1
Dim BackgroundWorkerArray As New ArrayList
Dim FilesArray As New ArrayList
Public WithEvents BackgroundWorker As New System.ComponentModel.BackgroundWorker
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If BackgroundWorkerArray.Count >= 12 Then
MsgBox("U heeft het maximale aantal van 12 downloads bereikt")
Exit Sub
Else
BackgroundWorkerArray.Add(New System.ComponentModel.BackgroundWorker)
End If
BackgroundWorker = BackgroundWorkerArray(BackgroundWorkerArray.Count - 1)
BackgroundWorker.RunWorkerAsync(BackgroundWorkerArray.Count) 'itemnummer als argument
End Sub
Private Sub BackgroundWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker.DoWork
Dim WebClient As New System.Net.WebClient
WebClient.DownloadFile(FilesArray(CInt(e.Argument) - 1), "c:\temp\" & e.Argument.ToString & ".nul")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FilesArray.Add("http://www.nxs.nl/files/100mb.bin")
FilesArray.Add("http://speedtest.bbned.nl/download/file100mb.bin")
FilesArray.Add("http://ns0.multikabel.net/100mb.nul")
FilesArray.Add("ftp://ftp.unnet.nl/speedtest/100mb.bin")
FilesArray.Add("http://www.kpnbroadbandvalley.nl/mxarena/downloads/100mb.bin")
FilesArray.Add("http://www2.versatel.nl/100mb.bin")
FilesArray.Add("http://speedtest.exsilia.net/100mb.bin")
FilesArray.Add("ftp://ftp.xs4all.nl/pub/test/100mb.bin")
FilesArray.Add("http://test.euroaccess.nl/100mb.bin")
FilesArray.Add("http://85.17.128.2/100mb.bin")
FilesArray.Add("http://test.tc2.leaseweb.net/100mb.bin")
FilesArray.Add("ftp://ftp.bit.nl/pub/speedtest/100mb.bin")
End Sub
End Class