Is it possible to simulate a stopwatch with IsHighResolution = false when by default it's true?
views:
38answers:
2is it possible to simulate a stopwatch with IsHighResolution = false when by default it's true?
Based on the documentation and a quick look in Reflector, I will offer a tentative no.
Here's the relevant part from the documentation:
The timer used by the Stopwatch class depends on the system hardware and operating system.
IsHighResolution is a read-only field which is initialized by the (static) type initializer via a call to the QueryPerformanceFrequency Win32 API function (apparently from kernel32.dll).
If there's any way of changing this, I can't think of it it.
Adding to what @Mark says, the documentation also says
Otherwise, IsHighResolution is false, which indicates that the Stopwatch timer is based on the system timer.
I guess it means, you could use a regular timer.
See if this article helps you.
EDIT: Looking into reflector, it seems that the code relies on DateTime.Ticks if it is not a high resolution timer to start/stop.