silverlight后台定时器调用

(1) // 使用一个控制动画的脚本物件来实作计时器。
        Storyboard _timer = new Storyboard();

(2)   对定时事件初始化:

           _timer.Duration = TimeSpan.FromMilliseconds(3000);
            _timer.Completed += new EventHandler(_timer_Tick);

(3)  void _timer_Tick(object sender, EventArgs e)
        {

            int AA=rd.Next(25, 39);
            A.Text = AA.ToString();
            int VV = rd.Next(350, 380);
            V.Text =VV .ToString();
            HZ.Text = rd.Next(0, 25).ToString();
            KW.Text= (AA*VV).ToString();
            _timer.Begin();
            
        }
(4)调用或停止类似于普通动画:

  _timer.Begin();  

 _timer.Pause();

你可能感兴趣的:(Sliverlight)