作者: yuzhuo83
查看: 2048|回复: 3
打印 上一主题 下一主题

[求助] C#中while循环和线程问题

[复制链接]
楼主
乔克斯 发表于 2016-10-12 09:42:08 | 显示全部楼层
[C#] 纯文本查看 复制代码
public bool bool1;
public Thread three1;
private void button4_Click(object sender, EventArgs e) {
    bool1 = true;
    three1 = new Thread(test);
    three1.Start();
}

private void button5_Click(object sender, EventArgs e) {
    try {
        bool1 = false;
        three1.Abort();
        //关闭资源
    } catch (Exception ex) { }
}

public void test() {
    while (bool1) {
        //资源使用

    }
}
您需要登录后才可以回帖 登录 | 加入CSkin博客

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|CSkin ( 粤ICP备13070794号

Powered by Discuz! X3.2  © 2001-2013 Comsenz Inc.  Designed by ARTERY.cn
GMT+8, 2024-5-6 16:22, Processed in 0.543454 second(s), 29 queries , Gzip On.

快速回复 返回顶部 返回列表