vb.net 2010怎么多线程
简单点就行,我对.net不怎么懂只要同时运行代码A和代码B就行了就比如VB6中的:privatesubcommand1_click()a=1b=2endsub这个代码只能...
简单点就行,我对.net不怎么懂
只要同时运行代码A和代码B就行了
就比如VB6中的:
private sub command1_click()
a=1
b=2
end sub
这个代码只能是先让a=1,再让b=2,怎么同时让a=1,b=2? 展开
只要同时运行代码A和代码B就行了
就比如VB6中的:
private sub command1_click()
a=1
b=2
end sub
这个代码只能是先让a=1,再让b=2,怎么同时让a=1,b=2? 展开
展开全部
Private a As Integer
Private b As Integer
Private Sub setA()
a = 1
End Sub
Private Sub setB()
b = 2
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim t1 As Threading.Thread
Dim t2 As Threading.Thread
t1 = New Threading.Thread(AddressOf setA)
t2 = New Threading.Thread(AddressOf setB)
t1.Start()
t2.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MessageBox.Show("a=" & a & ",b=" & b)
End Sub
Private b As Integer
Private Sub setA()
a = 1
End Sub
Private Sub setB()
b = 2
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim t1 As Threading.Thread
Dim t2 As Threading.Thread
t1 = New Threading.Thread(AddressOf setA)
t2 = New Threading.Thread(AddressOf setB)
t1.Start()
t2.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MessageBox.Show("a=" & a & ",b=" & b)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |