Differences in Elapsed Ticks property of Stopwatch

拟墨画扇 提交于 2019-12-04 18:54:22

问题


ElapsedTicks & Elapsed.Ticks are properties of Stopwatch, which I think should be same. And in case they are same, why they should give different outputs ?

Code :

Stopwatch spwt = Stopwatch.StartNew();
spwt.Stop();
Console.WriteLine(spwt.ElapsedTicks);
Console.WriteLine(spwt.Elapsed.Ticks);

Output :

6
16

Why is this difference observed ? shouldn't it be same ?


回答1:


See http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.elapsedticks.aspx:

Note Stopwatch ticks are different from DateTime.Ticks. Each tick in the DateTime.Ticks value represents one 100-nanosecond interval. Each tick in the ElapsedTicks value represents the time interval equal to 1 second divided by the Frequency.



来源:https://stackoverflow.com/questions/7432735/differences-in-elapsed-ticks-property-of-stopwatch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!