Threading?

winzone

New member
Joined
Aug 20, 2010
Messages
1
Programming Experience
Beginner
Hi All,

Now currently i have 3 thread work I want to run 2 thread at a time and after finished thread 1 or 2, run thread 3.
My problem is how to know thread 1 or 2 is finished or not ? if finished want to run thread 3.

Private Sub btnRunThread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRunThread.Click
Dim cThread As New ThreadClass
Dim ThreadMethod1 As New ThreadStart(AddressOf cThread.ThreadMethod1)
Dim MyThread1 As New Thread(ThreadMethod1)
Dim ThreadMethod2 As New ThreadStart(AddressOf cThread.ThreadMethod2)
Dim MyThread2 As New Thread(ThreadMethod2)
MyThread1.Name = "Thread Number 1 "
MyThread1.Priority = ThreadPriority.Normal
MyThread1.Start()
MyThread2.Name = "Thread Number 2 "
MyThread2.Priority = ThreadPriority.Highest
MyThread2.Start()
End Sub

Public Class ThreadClass
Public Sub ThreadMethod1()
For i As Integer = 1 To 100
Console.WriteLine("Time is " & i & " : " & Hour(Now) & " : " & Minute(Now) & " : " & Second(Now))
Next
T1 = 1
End Sub

Public Sub ThreadMethod2()
For i As Integer = 1 To 100
Console.WriteLine("Thread 2 : " & i)
Next
End Sub
End Class
 
Top Bottom