VB.NET 多线程建立运行
代码示例,方便以后查阅
Private Sub Start_1() '线程1
Dim I As Integer
For I = 1 To 100000000 Step +1
Label1.Text = I
Next
End Sub
Private Sub Start_2() '线程2
Dim I As Integer
For I = 100000000 To 1 Step -1
Label2.Text = I
Next
End Sub
Private Sub Start_3() '线程3
Dim I As Integer
For I = 1 To 100000000 Step +1
Label3.Text = I
Next
End Sub
Private Sub Start_4() '线程4
Dim I As Integer
For I = 100000000 To 1 Step -1
Label4.Text = I
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Control.CheckForIllegalCrossThreadCalls = False
Dim XC_1 As New Threading.Thread(AddressOf Start_1)
XC_1.Start()
Dim XC_2 As New Threading.Thread(AddressOf Start_2)
XC_2.Start()
Dim XC_3 As New Threading.Thread(AddressOf Start_3)
XC_3.Start()
Dim XC_4 As New Threading.Thread(AddressOf Start_4)
XC_4.Start()
End Sub
摘自Shine的圣天堂-〃敏〃