win32 timers

Started by
1 comment, last by TimMisiak 17 years, 1 month ago
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?
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.
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.

This topic is closed to new replies.

Advertisement