zoukankan      html  css  js  c++  java
  • Silverlight 计时器

    代码
    public partial class MainPage : UserControl
    {
    int i = 1;
    TextBlock myTextBlock;
    public MainPage()
    {
    InitializeComponent();
    myTextBlock
    = new TextBlock();
    myTextBlock.Loaded
    += this.StartTimer;
    myTextBlock.Margin
    = new Thickness(30);
    LayoutRoot.Children.Add(myTextBlock);
    }
    public void StartTimer(object o, RoutedEventArgs sender)
    {
    //创建计时器
    System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
    //创建间隔时间
    myDispatcherTimer.Interval = new TimeSpan(0,0,0,1);
    //创建到达间隔时间后需执行的函数
    myDispatcherTimer.Tick += new EventHandler(Each_Tick);
    //开启计时器
    myDispatcherTimer.Start();
    }

    public void Each_Tick(object o, EventArgs sender)
    {
    myTextBlock.Text
    = i++.ToString() + "";
    }
    }
  • 相关阅读:
    逆元(费马小定理求法)
    CodeForces
    lower_bound and upper_bound
    HDU 4825 Xor Sum
    1030: [JSOI2007]文本生成器
    1070: [SCOI2007]修车
    agc 027 B
    P2664 树上游戏
    CF 314 E. Sereja and Squares
    4237: 稻草人
  • 原文地址:https://www.cnblogs.com/hl3292/p/1891696.html
Copyright © 2011-2022 走看看