我有一个字符串,其中包含我要下载的图片的多个网址,我正在拆分此字符串并将每个网址存储在一个数组中然后在数组中循环以获取每个网址并下载它,但应用程序挂起直到所有这个事件已经完成。这是我的代码:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim cnt As Integer = 1
Dim singleUrl As String() = allPicsURL.Split(New Char() {","c})
ReDim Preserve singleUrl(UBound(singleUrl) - 1)
For j As Integer = 0 To singleUrl.Length() - 1
My.Computer.Network.DownloadFile(singleUrl(j), "F:\Users\Dany\Pictures\Test\" & Date.Now().ToFileTime & ".jpeg")
cnt += 1
Next
MsgBox(cnt - 1 & " Pictures were saved!", MsgBoxStyle.OkOnly)
End Sub
如何阻止我的申请冻结?