你可以在t1关闭前关闭掉thread吗?

解决方案 »

  1.   

    panyee(快乐王子) :
    我就是想那样做
      

  2.   

    show your code or tryProcess p = ...
    p.Start();
    p.WaitForExit();if you need to terminate the thread,Process p = null;
    try
    {}
    catch (ThreadInterruptedException ex)
    {
      if (p != null)
           p.Kill();
    }
      

  3.   

    楼主看来是对Process和Thread的概念没弄清楚
      

  4.   

    我的一种思路是:
    JudgeSystem js = new JudgeSystem(sourceFilename, no);
    Thread judge = new Thread(new ThreadStart(js.judge));
    judge.Start();

    Thread.Sleep(6000); //计时
    if(judge.IsAlive)
    {
         judge.Abort(); // 这种做法无法把judge里开出的process停止,而且如果judge没到
                        //6000就停止了,没法关掉计时线程
    }另一种:在js.judge()里面,即用process的地方Process execute = new Process();
    //......
    execute.Start();
    //...... Thread.Sleep(6000);
    if(!execute.HasExited)
    {
         execute.Kill(); //这样可以关掉process execute了,但是每次肯定要延时6000
    }我怎么才能改成我想要的功能(见楼顶)呢?
      

  5.   

    to yqdeng(抓紧每一天,迎接新挑战) :
    process是进程
    thread是线程
    是酱紫吗?
      

  6.   

    线程停了,进程哪会自动Kill
      

  7.   

    那如果process执行期间发生内存错误等异常,用ThreadInterruptedException可以捕捉得到吗?