Jump to content
  • Advertisement
Sign in to follow this  
TimMisiak

win32 timers

This topic is 4227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I used to use standard win32 timer events (IE, SetTimer/WM_TIMER) in my programs until I started to realize that alot of bad stuff happens with these timers. For instance, certain scenarios can cause timer events to never get to your message queue (or get there very delayed). So I've been looking for an alternative, and I've come to the conclusion that I need to use the multimedia timers (IE, timeSetEvent) or the timer queue interface (IE, CreateTimerQueue). I've heard that multimedia timers are "obsolete" and that timer queues are prefered, but I don't see a whole lot of code using timer queues. Can anyone comment on which is better?

Share this post


Link to post
Share on other sites
Advertisement
I can't read anywhere in the documentation (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_timesetevent.asp) the multimedia timer is obsolete or deprecated, but perhaps it's just common sense not to use them... :)
I have never seen the CreateTimerQueue functions but those doesn't seem to bad I guess. The main way to use timers in game programming that I have seen is to use high-resolution performance counters (http://msdn2.microsoft.com/en-us/library/ms644904.aspx). These counters are not asynchronous, so they have to be used in the PeekMessage() loop to poll for time change, but they are very accurate.

Share this post


Link to post
Share on other sites
Yeah, the documentation doesn't explicitly call them "obsolete", but Larry Osterman is a guy on the windows multimedia team, and he says that Timer Queues should be prefered: http://blogs.msdn.com/larryosterman/archive/2005/09/08/462477.aspx.

QueryPerformanceCounter is okay, but it's a pretty heavy-weight function, and I want to avoid using polling, since I want to be friendly to other applications.

I think I'll do more research on this some other time, but I'm just using multimedia timers for now. I don't see any disadvantage to using them yet.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!