| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2941 人关注过本帖
标题:敬请各位高手解决vb.net(VS2010)多线程的问题。谢谢。
取消只看楼主 加入收藏
HVB6
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:15
帖 子:331
专家分:561
注 册:2013-10-30
结帖率:98.41%
收藏
已结贴  问题点数:20 回复次数:0 
敬请各位高手解决vb.net(VS2010)多线程的问题。谢谢。
以下代码在(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
搜索更多相关主题的帖子: Private Sub End Thread Threading 
2017-07-16 16:53
快速回复:敬请各位高手解决vb.net(VS2010)多线程的问题。谢谢。
数据加载中...
 
   



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

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