Windows Phone 7上几种实现Timer效果的方法

来源:互联网 发布:轻松卸载软件下载 编辑:程序博客网 时间:2024/05/16 15:45

对于Silverlight程序,可以使用下面的方法模拟

1.   使用DispatcherTimer.

      System.Windows.Threading.DispatcherTimer dpt = new System.Windows.Threading.DispatcherTimer();
      dpt.Interval = new TimeSpan(0, 0, 1);
      dpt.Tick += new EventHandler(dpt_Tick);
      dpt.Start();

2. 使用Storyboard模拟

            timer = new Storyboard();
            timer.Duration = TimeSpan.FromMilliseconds(200);

            timer.Completed += new EventHandler(timer_Completed);            
            timer.Begin();

 

        void timer_Completed(object sender, EventArgs e)
        {
            client.GetReportAsync();
            timer.Begin();
        }