关于VB的线程
'FORM中
Private Sub Command1_Click()
hThread1 = CreateThread(0&, 0&, AddressOf ThreadProc1, _
0&, 0&, 1)
hThread2 = CreateThread(0&, 0&, AddressOf ThreadProc2, _
0&, 0&, 2)
End Sub
Private Sub Command2_Click()
If hThread1 <> 0 Then TerminateThread hThread1, 0
If hThread2 <> 0 Then TerminateThread hThread2, 0
End Sub
'模块中
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
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 TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public hThread1 As Long, hThread2 As Long
Public Sub ThreadProc1(ByRef Param As Long)
While True
'Sleep 2000
MsgBox "TH1"
Wend
End Sub
Public Sub ThreadProc2(ByRef Param As Long)
While True
'Sleep 2000
MsgBox "TH2"
Wend
End Sub
为什么没反映啊?
该怎么做?
问题点数:0、回复次数:0Top




