| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 503 人关注过本帖
标题:怎么用取消键停止辅助线程???代码如下
只看楼主 加入收藏
wangcqing
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-3-16
收藏
 问题点数:0 回复次数:0 
怎么用取消键停止辅助线程???代码如下
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace VC2008programm
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }
      //  private Thread thread = new Thread(ThreadProc);
        private void button1_Click(object sender, EventArgs e)
        {
            Thread thread = new Thread(new ThreadStart(ThreadProc));
            thread.IsBackground = true;   
        
thread.Start();

           
this.button1.Enabled = false;

        
        }
        public  void ThreadProc()
        {
            for (int i = 0; i < 500; i++)
            {
                OutText(i.ToString());
                Thread.Sleep(100);
               
            }
        }
        public delegate void OutDelegate(string text);

        public void OutText(string text)
        {
            if (txt.InvokeRequired)
            {
                OutDelegate outdelegate = new OutDelegate(OutText);
                this.BeginInvoke(outdelegate, new object[] { text });
                return;
            }
            txt.Items.Add(text);
           // txt.AppendText("\t\n");
        }

        private void Form4_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
        停止辅助线程的语句怎么写?

        }


    }
}
搜索更多相关主题的帖子: 辅助 代码 线程 
2010-03-16 11:18
快速回复:怎么用取消键停止辅助线程???代码如下
数据加载中...
 
   



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

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