zoukankan      html  css  js  c++  java
  • C# 通过System.Timers.Timer获取时间

     1 public delegate void timeDelegate();// Timer获取时间
     2 
     3 private void Form1_Load(object sender, EventArgs e)
     4 {
     5     System.Timers.Timer t = new System.Timers.Timer(1000); //设置时间间隔为5秒
     6     t.Elapsed += new System.Timers.ElapsedEventHandler(Timer_TimesUp);
     7     t.Enabled = true; //是否触发Elapsed事件
     8     t.AutoReset = true; //每到指定时间Elapsed事件是触发一次(false),还是一直触发(true)
     9 }
    10 private void Timer_TimesUp(object sender, System.Timers.ElapsedEventArgs e)
    11 {
    12     timeDelegate td = new timeDelegate(timeChange);
    13     this.BeginInvoke(td);
    14 }
    15 public void timeChange()
    16 {
    17     int hour = System.DateTime.Now.Hour;
    18     int minute = System.DateTime.Now.Minute;
    19     int second = System.DateTime.Now.Second;
    20     textBox1.Text = hour.ToString();
    21     textBox2.Text = minute.ToString();
    22     textBox3.Text = second.ToString();
    23 }
  • 相关阅读:
    cookie操作和代理
    发起post请求
    scrapy核心组件
    爬取多个url页面数据--手动实现
    scrapy之持久化存储
    selenium + phantomJs
    scrapy框架简介和基础使用
    校验验证码 实现登录验证
    beautifulsoup解析
    xpath
  • 原文地址:https://www.cnblogs.com/shelly0307/p/7592611.html
Copyright © 2011-2022 走看看