Public Sub CountSheep()
Dim i As Integer = 1 ' Sheep do not count from 0.
Do While (True) ' Endless loop.
Console.WriteLine("Sheep " & i & " Baah")
i = i + 1
System.Threading.Thread.Sleep(1000) 'Wait 1 second.
Loop
End Sub
Sub UseThread()
Dim t As New System.Threading.Thread(AddressOf CountSheep)
t.Start()
End Sub
VB.NET的示例使用 AddressOf 运算符来指定线程的启动函数(多线程)
最新推荐文章于 2024-01-19 21:51:54 发布
本文介绍了一个使用Visual Basic编写的简单程序,该程序通过无限循环来模拟数羊的过程,并利用线程使计数在后台运行,每秒钟输出一次当前计数的羊的数量。
4613

被折叠的 条评论
为什么被折叠?



