定时执行某个方法

            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(interval);
            timer.Tick += (s, e) =>
            {
                LayoutRoot.Background = new ImageBrush()
                {
                    ImageSource = new BitmapImage(new Uri("Animation/Loading/0" + imageIndex + ".png", UriKind.Relative)),AlignmentX= AlignmentX.Center,AlignmentY = AlignmentY.Center
                };
                imageIndex = imageIndex < 8 ? imageIndex + 1 : 1;
            };
            timer.Start();

posted @ 2012-08-11 14:06  狄大人  阅读(305)  评论(0编辑  收藏  举报