cj-2307
cj-2307

Reputation: 311

microsecond timer in windows

I'm using C ++ Builder to develop a windows application, and I need to call a function periodically with the time interval given in microseconds. The TTimer class of C ++ Builder only allows me to set this interval in milliseconds. Also I tried to use the Waitable timers of Windows (https://learn.microsoft.com/en-us/windows/win32/sync/using-a-waitable-timer-with-an-asynchronous-procedure-call), but also the time can only be adjusted in milliseconds. Is there a way to implement similar functionality in microseconds?

Upvotes: 1

Views: 2248

Answers (1)

Kieveli
Kieveli

Reputation: 11075

It used to be the case that minimal resolution on a timer was +- 10 ms. Even setting a timer on 1ms would not happen after 1ms, but somewhere around 7-10 ms (and occasionally much longer). Finer resolution on a timer, in Windows, would be pointless in this case. You cannot depend upon a timer for rapid response times, nor can you anticipate when your program may be swapped out of the CPU by the OS.

Upvotes: 2

Related Questions