控制台程序动态显示时间

 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();
        }

   }
posted @ 2012-05-16 18:35  盈不足  阅读(342)  评论(0编辑  收藏  举报