[RESOLVED] Controling Threads
Code:
Imports System.Threading
Imports System.IO
Public Class Form1
Public iPath As String
Public cnt As Integer
Shared locker As Object = New Object()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Startdownload.Click
Dim sr As New StreamReader(TextBox1.Text)
Dim strLine As String
strLine = sr.ReadLine()
Do Until strLine Is Nothing
cnt = cnt + 1
iPath = strLine
strLine = sr.ReadLine()
StartThread()
Loop
sr.Close()
End Sub
Private Sub DownloadFile()
Dim url As String
Dim localFileName As String
On Error Resume Next
My.Computer.Network.DownloadFile _
(url, _
localFileName)
Next i
End Sub
Private Sub StartThread()
Dim nthread As Thread
nthread = New Thread(AddressOf DownloadFile)
nthread.Start()
End Sub
End Class
I am downloading 500 file from internet but it freeze my form utile it's completed so i have tried Thread but it starts all the Thread at once and i don't get all the files.... how can i control the Thread execution? i want that until one file is not completed dont go for other file or loop. i have tried SyncLock but really don't know how to use SyncLock plz help