DisppatcherTimer是一个比较常用的计时器对象,其使用非常简单,位于using System.Windows.Threading命名空间下,如下演示一个获取系统时间的例子:

        public CygBrowser()
        {
            InitializeComponent();          
            DispatcherTimer timer = new DispatcherTimer();
            //设置一个间隔时间
            timer.Interval = new TimeSpan(0, 0, 1);
            //事件处理
            timer.Tick += new EventHandler(timer_Tick);            
            timer.Start();
        }

        void timer_Tick(object sender, EventArgs e)
        {
            textBlock1.Text = "当前系统时间为:"+DateTime.Now.ToLongTimeString();
        }

  

silverlight计时器的使用

相关文章:

  • 2021-11-16
  • 2021-08-28
  • 2022-01-02
  • 2021-10-25
  • 2021-08-25
  • 2021-11-23
  • 2021-05-20
猜你喜欢
  • 2021-10-19
  • 2022-12-23
  • 2021-10-14
  • 2021-07-05
  • 2021-12-13
  • 2021-10-13
相关资源
相似解决方案