关于线程的结束!

shawls 2002-03-15 10:09:28
关于线程的结束!
我创建线程以后,如何结束?

例如
button1里面:

dim t as system.threading.thead
t=new system.threading.thead(addressof newproess)
t.start()

我点两次button1以后,就会开两个线程!

如何在我点以前终止以前的线程??

我用t.about没有用牙!

...全文
29 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
b28 2002-10-13
  • 打赏
  • 举报
回复
就是就是!
sumtec 2002-05-08
  • 打赏
  • 举报
回复
beta2 里面没有这个问题,只要你按代码规范写的话.(也就是上面那个例子啦)
shawls 2002-03-15
  • 打赏
  • 举报
回复

我用的是beta2

也有这个问题?

march98 2002-03-15
  • 打赏
  • 举报
回复
你用的是以前版本的vb,正式版修正了这个bug.
即使是你现在的版本,也有一个解决办法(在正式版中也通用)
例:
Imports System
Imports System.Windows.Forms
Imports System.Threading


Class ThreadExample
' The method that will be called when the thread is started.
Sub MyThreadProc()
Dim i As Integer
i = 1


Try

For i = 1 To 30000
Console.WriteLine("ThreadExample MyThreadProc is running on another thread")
Next i

Catch e As ThreadAbortException

Console.WriteLine("要死")

End Try
End Sub
End Class


Module Module1

Sub Main()
Console.WriteLine("Thread Simple Sample")
Dim oThreadExample As New ThreadExample()
' Create a ThreadStart object, passing the address of oThreadExample.MyThreadProc.
' Note that Visual Basic is using syntactic sugar here. The constructor
' for ThreadStart actually takes two parameters: an object
' and the address of the method body.
Dim otter As New ThreadStart(AddressOf oThreadExample.MyThreadProc)
' Create a Thread object.
Dim oThread As New Thread(otter)
' Starting the thread invokes the ThreadStart delegate.
oThread.Start()
oThread.Abort()
Console.ReadLine()

End Sub

End Module
march98 2002-03-15
  • 打赏
  • 举报
回复

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧