Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
700 views
in Technique[技术] by (71.8m points)

.net - Are Stopwatch.ElapsedTicks and Stopwatch.Elapsed.Ticks always the same?

What does ElapsedTicks and Elapsed.Ticks in the Stopwatch class mean? When could the meaning be different than intended?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I just found out that ElapsedTicks in the Stopwatch class doesn't mean real "ticks" if StopWatch.IsHighResolution is true.

Note (if IsHighResolution is True - from Microsoft Connect link (now dead)):

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.

You can do the math above or it seem you can use StopWatch.Elapsed.Ticks instead of StopWatch.ElapsedTicks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...