16,554
社区成员
发帖
与我相关
我的任务
分享
Dim t As System.Threading.Thread
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
t = New System.Threading.Thread(AddressOf Me.showdata)
'线程调用子程序
t.Start()'线程开始
End Sub
dim txtsql As String
Sub showdata()
Try
System.Threading.Thread.CurrentThread.Sleep(20)
txtSQL = "select ...."
' 查询功能
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
t.Join()'线程暂停
t.Abort()'线程中止
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub