This article describes a simple implementation method of timers in C#. Share it for your reference, as follows:
startTime = ; DispatcherTimer dt = new DispatcherTimer(); = new TimeSpan(0, 0, 1); += new EventHandler(dt_Tick);//Calling the function(); void dt_Tick(object sender, EventArgs e) { timeSpan = (startTime); //Use TimeSpan to format the time = ("{0:00}:{1:00}:{2:00}", (int),, ); // Use DateTime to format the time = ("{0:HH:mm:ss}", new DateTime()); }
For more information about C# related content, please check out the topic of this site:Summary of C# date and time operation skills》、《Summary of C# string operation skills》、《Summary of C# array operation skills》、《Summary of XML file operation skills in C#》、《Tutorial on the usage of common C# controls》、《Summary of WinForm control usage》、《C# data structure and algorithm tutorial"and"Introduction to C# object-oriented programming tutorial》
I hope this article will be helpful to everyone's C# programming.