Imports System
Imports System.Threading
Public Class MyTestApp
Public Shared Sub Main()
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异常 。使终结的线程可以捕获到异常但是很难控制恢复 , 仅有的办法是调用Thread.ResetAbort()来取消刚才的调用 , 而且只有当这个异常是由于被调用线程引起的异常 。因此,A线程可以正确的使用Thread.Abort()方法作用于B线程,但是B线程却不能调用Thread.ResetAbort()来取消Thread.Abort()操作 。
【vb.net需要语句结束 vb缺少语句结束then】关于vb.net需要语句结束和vb缺少语句结束then的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
- mysql 判断 mysql的判断语句
- mongo sql语句 mongodb写sql语句
- mysql显示表的语句 mysql表示例
- mongodb数据库语句 mongodb数据库文档
- mongodb查询语句大全 mongodb查询最新时间
- mongodb聚合查询优化 mongodb聚合运算需要索引吗
- mysql主键需要加索引吗 mysql加主键过程原理
- mysql需要花钱吗 mysql什么情况下免费
- mysql转换字符类型 mysql语句中转义
- mongodb nosql mongodb的sql语句
