下面的是用于 开辟线程和 终止线程的 ,但是 用了这函数后 用于处理线程中的事件不生效        private Thread AC_T1 = null;//建立对象
下面是函数private delegate void ThreadProcTemp();
        private void Check_IsCheck(CheckBox cb, ref Thread thr, ThreadProcTemp temp, bool bStatus, Label showStatus)
        {
            if (cb.Checked)
            {
                bStatus = true;                thr = new Thread(new ThreadStart(temp));
                
                thr.Start();
                showStatus.ForeColor = Color.Green;
                showStatus.Text = Convert.ToString(thr.ThreadState);
            }
            else
            {
                bStatus = false;
                thr.Join();                showStatus.ForeColor = Color.Red;
                showStatus.Text = Convert.ToString(thr.ThreadState);
            }
        }
使用
       private void Check_T1(object sender, EventArgs e)
        {
            Check_IsCheck(IsOpen, ref AC_T1, ThreadProc1,Status, Status2); 
        }        private static void ThreadProc1()
        {      
         
            while (Status)
            {
   
            }
        }
请教一下看那线程的状态的开启的但是 那委托处理的事件就是没有执行 不知道是什么问题

解决方案 »

  1.   

    没有必要自己定义个委托吧?
    thr = new Thread(new ThreadStart(temp));ThreadStart就是一个委托
    你只需传递与其签名相同的方法就好了 还有就是ThreadProcTemp 
    你定义了它 但是你并没有与方法绑定
      

  2.   

     private void Check_IsCheck(CheckBox cb, ref Thread thr, ThreadProcTemp temp, bool bStatus, Label showStatus)中的ThreadProcTemp temp 改为ThreadStart temp 不需要自己再定义委托了
      

  3.   

    Thread 在new时 传入方法 就可以了
      

  4.   

    private static void ThreadProc1()
            {      
             
                while (Status)
                {
       
                }
            }
    空方法啊,执行了你怎么看出来