Recently, the timing function has been used in the program to time a certain module. The module also needs to be paused when it is paused, and the timing continues when it is started.
Used Stopwatch
The namespace of Stopwatch is using;
using System; using ; using ; using ; using ; using ; using ; namespace ConsoleApp3 { class Program { static void Main(string[] args) { Stopwatch sw = new Stopwatch(); /////Reset to zero //(); ////Reset and start timing //(); //// End time //(); //Get the run time interval TimeSpan ts = ; //Get the run time [milliseconds] long times = ; //Get the total run time long times2 = ; //Judge whether the timing is in progress [true is timing] bool isrun = ; //Get the timing frequency long frequency = ; //Time starts (); (1000); //Time ends (); (); (); (2000); (3000); } } }
Students who need further research can view the official documents
Stopwatch Class () | Microsoft Docs
This is the article about using the Stopwatch timer in C# to pause the timer and continue to count. For more related content of the Stopwatch timer, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!