¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Windows timeBeginPeriod() behavior changes


 

¿ªÔÆÌåÓý

Thanks for that. Good catch!

?

I use TimeBeginPeriod in my platform, but there are few places where the timer resolution is critical, and I must admit I hadn't noticed any problem running on either Windows 10 or 11. But I have a timer test program that visually shows up the issue quite nicely:

?

?

With the settings shown, the 'Average interval' field for Timer 1 should be close to 2.0 millisecs (I set the TimeBeginPeriod to the highest resolution, ie 1 millisec). But it's about 15, in line with what you said.

?

I suppose I should put the effort into adding the extra SetProcessInformation call, but at the moment there are more pressing things that need attention.

?

Richard

?

?

?

From: [email protected] <[email protected]> On Behalf Of Nick
Sent: 14 April 2022 15:09
To: [email protected]
Subject: [TWS API] Windows timeBeginPeriod() behavior changes

?

This is a heads-up for those of you doing lower level win32 programming with timeBeginPeriod().

Starting in Win 10 2004 the setting is no longer global and only effects the calling process.

Even more bizarre, from the timeBeginPeriod() Microsoft docs:

Starting with Windows 11, if a window-owning process becomes fully occluded, minimized, or otherwise invisible or inaudible to the end user, Windows does not guarantee a higher resolution than the default system resolution. See for more information on this behavior.

You have to explicitly declare that you don't want Windows to blatantly ignore your timer resolution settings.

Most programs that care will set the timer resolution so they will not be effected by the global/local change.

But if you have something that runs in the background and depends on a specific timer resolution you will have to add code to make it stick when the program is not "interactive".

The change to Win 10 was initially undocumented but eventually made it to timeBeginPeriod().

?

Join [email protected] to automatically receive all group messages.