multimedia timers synchronization
-
we have four threads which have to call with milliseconds interval (66.67ms,200ms,10ms,100ms these are time intervals for resuming threads) "windows timers" does not provide accuracy (perfect) by using windows timers results are not well accurate but if we use multimedia timers then there is problem of synchronization. processor does not takes windows event (mean mouse click or key pressed or repaint window etc etc these event take log time of interval to process ) we need much accuracy and fast user intraction with my application (mean click and key press etc etc) what can be solution? and how can sychronize windows events with multimedia timers??
-
we have four threads which have to call with milliseconds interval (66.67ms,200ms,10ms,100ms these are time intervals for resuming threads) "windows timers" does not provide accuracy (perfect) by using windows timers results are not well accurate but if we use multimedia timers then there is problem of synchronization. processor does not takes windows event (mean mouse click or key pressed or repaint window etc etc these event take log time of interval to process ) we need much accuracy and fast user intraction with my application (mean click and key press etc etc) what can be solution? and how can sychronize windows events with multimedia timers??
Are you trying to pass multimedia timer events into your window handling code or the other way round? If it's the first option and you're using
timerSetEvent
, you could do this:- For each timer events, create a kernel event.
- Create the the timer event using the flag
TIME_CALLBACK_EVENT_SET
and pass the kernel event handle as the callback procedure. - Create a thread with a function that (in a loop) does a
WaitForMultipleObjects
, waiting for any one of the kernel events set by the timers. - When an event is detected in the thread function, POST a window message as appropriate.
The general pattern of setting kernel events with timer events allows you to transfer the timer event into another thread. BTW - do you realise that the multimedia timer API is obsolete and could easily disappear soon? You might be better off using timer queues (see this article for a description[^]) that, as far as I can tell, have the same resolution and accuracy as multimedia timers. Also, it looks like they're better tied into the Windows synchronisation functionality.
-
Are you trying to pass multimedia timer events into your window handling code or the other way round? If it's the first option and you're using
timerSetEvent
, you could do this:- For each timer events, create a kernel event.
- Create the the timer event using the flag
TIME_CALLBACK_EVENT_SET
and pass the kernel event handle as the callback procedure. - Create a thread with a function that (in a loop) does a
WaitForMultipleObjects
, waiting for any one of the kernel events set by the timers. - When an event is detected in the thread function, POST a window message as appropriate.
The general pattern of setting kernel events with timer events allows you to transfer the timer event into another thread. BTW - do you realise that the multimedia timer API is obsolete and could easily disappear soon? You might be better off using timer queues (see this article for a description[^]) that, as far as I can tell, have the same resolution and accuracy as multimedia timers. Also, it looks like they're better tied into the Windows synchronisation functionality.
Stuart Dootson wrote:
do you realise that the multimedia timer API is obsolete and could easily disappear soon?
Hi Stuart, Where did you hear that? Link? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Stuart Dootson wrote:
do you realise that the multimedia timer API is obsolete and could easily disappear soon?
Hi Stuart, Where did you hear that? Link? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Mark Salsbery wrote:
Hi Stuart, Where did you hear that?
I told him. ;) :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Mark Salsbery wrote:
Hi Stuart, Where did you hear that?
I told him. ;) :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]So where did YOU hear that? ;P I don't see any indication that the multimedia timer APIs are deprecated. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
So where did YOU hear that? ;P I don't see any indication that the multimedia timer APIs are deprecated. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Mark Salsbery wrote:
So where did YOU hear that
If I remember well, Stuart Dootson told me. :rolleyes:
Mark Salsbery wrote:
I don't see any indication that the multimedia timer APIs are deprecated.
Because we should keep it secret. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Mark Salsbery wrote:
So where did YOU hear that
If I remember well, Stuart Dootson told me. :rolleyes:
Mark Salsbery wrote:
I don't see any indication that the multimedia timer APIs are deprecated.
Because we should keep it secret. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]CPallini wrote:
Because we should keep it secret.
ok. shhhhh :)
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Stuart Dootson wrote:
do you realise that the multimedia timer API is obsolete and could easily disappear soon?
Hi Stuart, Where did you hear that? Link? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
That's what I read into this page[^]. Looking at Larry Osterman's blog post[^] again, it's just
timeSetEvent
andtimeKillEvent
. -
That's what I read into this page[^]. Looking at Larry Osterman's blog post[^] again, it's just
timeSetEvent
andtimeKillEvent
.Excellent! Thank you :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Mark Salsbery wrote:
So where did YOU hear that
If I remember well, Stuart Dootson told me. :rolleyes:
Mark Salsbery wrote:
I don't see any indication that the multimedia timer APIs are deprecated.
Because we should keep it secret. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]CPallini wrote:
Because we should keep it secret
But now you've let the cat out of the bag!!! The boys'll be round to sort you out ;)
-
CPallini wrote:
Because we should keep it secret
But now you've let the cat out of the bag!!! The boys'll be round to sort you out ;)
It's only me....I won't tell anyone!
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
CPallini wrote:
Because we should keep it secret
But now you've let the cat out of the bag!!! The boys'll be round to sort you out ;)
Wow the cat is out, hence is alive: we should tell to Mr. Schroedinger... (or is the above another secret?) :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]