中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

C# timer定時(shí)在屏幕上輸出信息的代碼

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線(xiàn)!快速搭建集群,上萬(wàn)Linux鏡像隨意使用

這段c#代碼通過(guò)timer定時(shí)器每隔5秒鐘調(diào)用一次OnTimerElapsed事件,在屏幕上輸出信息,這是一個(gè)簡(jiǎn)單的timer定時(shí)器使用范例,可以大概了解一些C#中timer的用法

using System;
using System.Timers;
  
public class Program
{
    private static System.Timers.Timer testTimer;
  
    public static void Main(string[] args)
    {
        testTimer = new System.Timers.Timer(5000); // 5 seconds
        testTimer.Elapsed += new ElapsedEventHandler(OnTimerElapsed);
  
        testTimer.Interval = 5000;
        testTimer.Enabled = true;
  
        Console.WriteLine("Press the enter key to stop the timer");
        Console.ReadLine();
  
    }
  
    private static void OnTimerElapsed(object source, ElapsedEventArgs e)
    {
        Console.WriteLine("Timer elapsed at {0}", e.SignalTime);
    }
}

標(biāo)簽: 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:javascript常用工具函數(shù)

下一篇:一個(gè)專(zhuān)門(mén)用于處理人民幣金額大小寫(xiě)的C#類(lèi)