日期:2014-05-19  浏览次数:21028 次

多线程问题,如何启动一个线程去轮殉一个static变量值?
如下所示
class   1
{
      private   static   bool   isDownload;
     

      public   Dee
      {
              //在此方法中要启动一个线程去轮询static值
              //if(null   ==   isDownload)
              //     Agent.Install()
      }
     
}
请问怎么写?谢谢告知。一分不少。

------解决方案--------------------
如下所示
class 1
{
private static bool isDownload;


public Dee
{
//在此方法中要启动一个线程去轮询static值
//if(null == isDownload)
// Agent.Install()
Thread t = new Thread(new ThreadStart(mydo));
t.start();
}
private void myDo()
{
while(true)
{
if(null == isDownload)
Agent.Install();

Thread.Sleep(100);
}
}
}