给自己做记录,看是否能帮助到大家吧
主要是 Stopwatch ,在命名空间
using System.Diagnostics;
让直接实例取对象就行。
Stopwatch sp = new Stopwatch();
sp.Start();
sp.Stop();
TimeSpan s = sp.Elapsed;//timespan是指总的耗时,可以单独取时间的时,分,秒,来看程序耗时
再贴几个拓展了解,只是概念性的,具体操作看自己咯。
system.Timers.timer多线程定时器
System.Windows.Threading.DispatcherTimer 单线程计时器
另外微软官方文档也有详细介绍,