vb.net多线程暂停 vb多线程编程( 二 )


Dim t As New Thread(New ThreadStart(AddressOf MyThreadMethod))
'Start the thread
t.Start()
MsgBox("Are you ready to kill the thread?")
'Kill the child thread and this will cause the thread raise an exception
t.Abort()
' Wait for the thread to exit
t.Join()
MsgBox("The secondary thread has terminated.")
End Sub
Shared Sub MyThreadMethod()
Dim i As Integer
Try
Do While True
Thread.CurrentThread.Sleep(1000)
Console.WriteLine("This is the secondary thread running.")
Loop
Catch e As ThreadAbortException
MsgBox("This thread is going to be terminated by the Abort method in the Main function")
End Try
End Sub
End Class
Thread.Abort()方法用来永久销毁一个线程vb.net多线程暂停 , 而且将抛出ThreadAbortException异常 。使终结的线程可以捕获到异常但是很难控制恢复vb.net多线程暂停,仅有的办法是调用Thread.ResetAbort()来取消刚才的调用,而且只有当这个异常是由于被调用线程引起的异常 。因此,A线程可以正确的使用Thread.Abort()方法作用于B线程,但是B线程却不能调用Thread.ResetAbort()来取消Thread.Abort()操作 。
VB.net 多线程 , 导致无法响应用
t.Suspend() 这个是挂起线程 。是一个异步方法 。
t.Sleep vb.net多线程暂停我看vb.net多线程暂停了是一个同步方法 。要等这个方法运行完vb.net多线程暂停了才继续下一步 。
这和from.show和 from.showdiaglog区别差不多!
至于疑问2我也没找到原因 。
vb.net多线程暂停的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb多线程编程、vb.net多线程暂停的信息别忘了在本站进行查找喔 。

推荐阅读