| 网站首页 | 业界新闻 | 群组 | 人才 | 技术文章 | 下载频道 | 博客 | 代码贴 | 编程论坛
绝地游戏外挂辅助教学千里之行 始于足下
共有 250 人关注过本帖
标题:敬请各位高手解决vb.net(VS2010)多线程的问题。谢谢。
取消只看楼主 收藏
HVB6
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:6
帖 子:262
专家分:374
注 册:2013-10-30
结帖率:100%
  已结贴   问题点数:20  回复次数:0   
敬请各位高手解决vb.net(VS2010)多线程的问题。谢谢。
以下代码在vb.net(VS2010)测试正常。
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 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()
         MessageBox.Show ("a=" & a & ",b=" & b)
    End Sub
2017-07-16 16:53







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.098994 second(s), 9 queries.
Copyright©2004-2017, BCCN.NET, All Rights Reserved