控制台程序动态显示时间
public class WindowHelper
{
public static void ShowTime(object userData)
{
int oldX = Console.CursorLeft;
int oldY = Console.CursorTop;
Console.SetCursorPosition(0, 0);
Console.Write(DateTime.Now.ToLongTimeString());
Console.CursorLeft = oldX;
Console.CursorTop = oldY;
}
}
class Program
{
static void Main(string[] args)
{
System.Threading.Timer clock = new Timer(WindowHelper.ShowTime, null, 0, 1000);
Console.ReadLine();
}