ITPub博客

首页 > 应用开发 > IT综合 > 在Vb下实现多线程 (转)

在Vb下实现多线程 (转)

原创 IT综合 作者:worldblog 时间:2007-12-11 09:56:30 0 删除 编辑
在Vb下实现多线程 (转)[@more@]

新建一Module
Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hobject As Long) As Long

Sub main()
  Load Form1
  Form1.Show
End Sub
Public Sub c1()
  .......
End Sub

Public Sub c2()
  ...... 
End Sub

新建一窗体

Private hthread1 As Long
Private hthread2 As Long
Private ithread1 As Long
Private ithread2 As Long

Private Sub Command1_Click()

ithread1 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1)  --创建线程一
ithread2 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1)  --创建线程二

CloseHandle ithread1  --关闭线程一
CloseHandle ithread2  --关闭线程二

End Sub

Private Sub Form_Load()

End Sub


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-991161/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    6241
  • 访问量
    2406177