当前位置:编程学习 > C#/ASP.NET >>

急!急!急!急!asp.net 关于线程的 一个问题

代码大致如下

switch(abc)
{
    case "start":
       Thread thr = new Thread(new ThreadStart(kkkk));
       thr.Start();

      break;
    case "close":
       if (thr.IsAlive)
       {
           thr.Abort();
       }
      break;
}

  case"close": 往后的代码 是不正确的 不能获取到我在start中声明的进程,如果把进程声明在switch 外面 在close里也不能很好判断。我尝试 在start 里面 给进程 thr 命名  但是 不知道怎么在close里找到这个命名的进程并关掉

总得来说我就是想在close 里 关掉 start 里声明的进程 望高手赐教。。。。一天了。。没头绪 --------------------编程问答-------------------- 楼主你得好好学习一样作用域的问题。。。。。。 --------------------编程问答-------------------- Thread   thr   单独 拿出去声明 --------------------编程问答--------------------
 Thread   thr   =   new   Thread(new   ThreadStart(kkkk)); 

switch(abc) 

        case   "start ": 
               thr.Start(); 

            break; 
        case   "close ": 
              if   (thr.IsAlive) 
              { 
                      thr.Abort(); 
              } 
            break; 



楼上2位说的 应该是这样。。但是   点击关闭再次进入页面后  thr又重新声明。 if   (thr.IsAlive) 
判断是false。 请大家再帮帮忙。。
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,