DispatcherTimer类的使用

  DispatcherTimer类位于System.Windows.Threading命名空间下,类似于winform的Timer类。
      
       {
        DispatcherTimer  timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += new EventHandler(timer_Tick);
        
        }
        void timer_Tick(object sender, EventArgs e)
        {
            tb.Text = DateTime.Now.ToLongTimeString();
        }
上面的代码演示了一个简单的时钟程序,每隔一秒中更新一次时间

ClockTest.rar下载

如何在wpf中使用Thread:http://blog.csdn.net/artlife/archive/2007/01/08/1477366.aspx
posted on 2006-11-05 18:45  stswordman  阅读(1094)  评论(0编辑  收藏  举报