怎么样能将一个程序按时间间隔依次执行?例如,每隔5秒运行一次程序(用C#代码来控制)!请高手帮忙!

解决方案 »

  1.   

    for(;;)
    {
       //执行一次
       System.Threading.Thread.Sleep(5000);
    }
      

  2.   

    while(true)
    {
     Threading.thread.sleep(5000);
     
     '运行你的代码
    }
      

  3.   

    对啊,用timer 的tick事件
    我这有thread的一段代码private void button4_Click_2(object sender, System.EventArgs e)
    {
    textBox1.PasswordChar = '*';
    Thread ttt = new Thread(new ThreadStart(t1));
    ttt.Start();

    }
    public void t1()
    {
    while(textBox1.Text!="tttttttttttt")
    {
    textBox1.Text+="t";
    System.Threading.Thread.Sleep(1000);
    }
    }
      

  4.   

    你的分真多,这些你按个f1就会在msdn中有的,看看.net指南
      

  5.   

    其實有時候只要在MSNDN上找找就有了.
    可能是樓主比較急用.