繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Asp.Net开发 >> 老外编的程序(七):Timed Thread Example

老外编的程序(七):Timed Thread Example

2007-07-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介: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 s...

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.");

// ...

}

}

责任编辑:admin
相关文章