扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:甘冀平 来源:yesky 2007年11月11日
关键字:
Imports System ' Import the threading namespace Imports System.Threading Public Class clsMultiThreading ' This is a simple method that runs a loop 5 times ' This method is the one called by the HelloWorldThreadingInVB ' class, on a separate thread. Public Sub OwnThread() Dim intCounter as integer For intCounter = 1 to 5 Console.WriteLine("Inside the class: " & intCounter.ToString()) Next End Sub End Class Public Class HelloWorldThreadingInVB ' This method is executed when this EXE is run Public Shared Sub Main() Dim intCounter as integer ' Declare an instance of the class clsMultithreading object Dim objMT as clsMultiThreading = new clsMultiThreading() ' Declare an instance of the Thread object. This class ' resides in the System.Threading namespace Dim objNewThread as Thread 'Create a New Thread with the Thread Class and pass ' the address of OwnThread method of clsMultiThreading class objNewThread = new Thread(new ThreadStart(AddressOf objMT.OwnThread)) ' Start a new Thread. This basically calls the OwnThread ' method within the clsMultiThreading class ' It is important to know that this method is called on another ' Thread, as you will see from the output objNewThread.Start() ' Run a loop and display count For intCounter = 10 to 15 Console.WriteLine("Inside the Sub Main: " & intCounter.ToString()) Next End Sub End Class |
vbc.exe Thread.vb /t:exe /debug /cls |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者