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

    RT,本篇记录C#中的计时函数的写法

    第一种:

                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = TimeSpan.FromMilliseconds(100);
                timer.Tick += Timer_Tick;
                timer.Start();
    
    
            //100毫秒执行一次
            private void Timer_Tick(object sender, EventArgs e)
            {}

    第二种:

                Timer time = new Timer(10);
                time.Elapsed += Time_Elapsed;
                time.Start();
             //10毫秒执行一次
            private void Time_Elapsed(object sender, ElapsedEventArgs e)
            {
                Console.WriteLine("time");
            }

     第三种  延时启动

    System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart((delegate {
                        Console.WriteLine("aaaaaaaaa");
                        judge.startFunc();
                    })
                ));//创建线程
    
                //thread.Start(3);    //延时三秒启动线程
                thread.Start();

    暂时只用了这几种,欢迎各位大神们将其他写法写在评论上,我也会随时添加上新的写法。

  • 相关阅读:
    beeline链接hive报错
    Java并发之FairSync和NonfairSync
    如何在 Linux 中将文件编码转换为 UTF-8
    Spring Boot运行原理
    jvm垃圾回收
    jvm调试工具
    Nginx相关
    docker 配置jar ,运行
    centos7的一些安装问题
    Docker
  • 原文地址:https://www.cnblogs.com/lingLuoChengMi/p/8005691.html
Copyright © 2011-2022 走看看