当前位置:开发者网络 >> 技术教程 >> .NET教程 >> 算法/线程 >> 内容
精彩推荐
分类最新教程
分类热点教程
  
老外编的程序(七):Timed Thread Example
作者:未知
日期:2003-07-12
人气:
投稿:Andy.m(转贴)
来源:未知
字体:
收藏:加入浏览器收藏
以下正文:
using System;
using System.Threading;


class App {
   public static void Main() {
      Console.WriteLine("Checking for status updates every 2 seconds.");
      Console.WriteLine("   (Hit Enter to termiante the sample)");
      Timer timer = new Timer(new TimerCallback(CheckStatus), null, 0, 2000);

      Console.Write("Press Enter to close window...");
      Console.Read();
   }


   // The callback method's signature MUST match that of a System.Threading.TimerCallback
   // delegate (it takes an Object parameter and returns void)
   static void CheckStatus(Object state) {
      Console.WriteLine("Checking Status.");
      // ...
   }
}
相关文章: