zoukankan      html  css  js  c++  java
  • C#学习Timer

          Timer类提供以指定的时间间隔执行方法的机制。此类不能继承。Timer能有规律的以一定的时间间隔激发timer事件,而执行相应的程序代码。Timer控件的Interval属性表示两个计时器事件之间的时间间隔,其值以ms为单位。Timer将每隔Interval触发一次计时器事件Tick。如:

    namespace mytimer
    {
       public partial class Timer:Form
      {
          public Timer()
          {
           InitializeComponent();
           }
    private int direction = 5;
    
    private void frmTimer_Load(object sender,EventArgs e)
    {
           cbInterval.SelectedIndex = 1;
    }
    
    private void btnMove_Click(object sender,EventArgs e)
    {
           timer1.Enabled = true;
    }
    
    private void timer_Tick(object sender,EventArgs e)
    {
           if(lblLogo.Left <= 0|| lblLogo.Right >= this.Width)
           {
                direction = -direction;
           }
           lblLogo.Left -= direction;
    }
    
    private void cbInterval SelectedIndexChanged(object sender,EventArgs e)
    {
           timer1.Interval = int.Parse(cbInterval.Text);
    } 
    }
  • 相关阅读:
    Java 一边读边写即读一行写一行
    mysql-字符类型
    mysql-数字类型:自增主键踩坑
    mysql-死锁
    mysql-查询的成本
    mysql-独立表空间
    mysql-innodb的表空间
    java-semaphore
    java-CyclicBarrier
    java-countDownLatch
  • 原文地址:https://www.cnblogs.com/virgil/p/2675241.html
Copyright © 2011-2022 走看看