zoukankan      html  css  js  c++  java
  • C# 计时器

    一、Stopwatch 主要用于测试代码段使用了多少时间

      使用方法:

          Stopwatch sw=new Stopwatch();

          sw.Start();

          ...

          sw.Stop();

          Console.WriteLine(sw.ElapsedMilliseconds);

    二、System.Timers.Timer 主要用于按时间间隔循环执行代码

      使用方法:

          System.Timers.Timer timer=new System.Timers.Timer(100);

          timer.Elapsed+=new ElapsedEventHandler(TickTimer);

          timer.Start();

          private void TickTimer(object sender, ElapsedEventArgs e){}  //必须是事件

  • 相关阅读:
    3.21上午
    3.17下午
    2017.4.14-morning
    2017.4.13-afternoon
    2017.4.13-morning
    2017.4.12-afternoon
    2017.4.12-morning
    2017.4.11-afternoon
    2017.4.11-morning
    2017.4.10-afternoon
  • 原文地址:https://www.cnblogs.com/alsofly/p/3375118.html
Copyright © 2011-2022 走看看