Discussion:
Questions regarding timeBeginPeriod() and timeEndPeriod()
(too old to reply)
Dillon Geo
2008-12-27 00:52:42 UTC
Permalink
Hi All,

The article in MSDN on timeBeginPeriod() and timeEndPeriod() says
"Call this function (timeBeginPeriod) immediately before using timer
services, and call the timeEndPeriod function immediately after you are
finished using the timer services."

I am confused by the above description. What do "the timer services"
include, all the functions associated with multimedia timer services, such
as the following?
timeGetSystemTime, timeGetTime, timeGetDevCaps, timeKillEvent,
TimeProc, timeSetEvent
I am also confused by "immediately before (after) using timer services". If
I have a loop that uses a timer service at each iteration, do I need to call
timeBeginPeriod and timeEndPeriod at each iter iteration, like the
following?

while(1){
timeBeginPeriod ();
t = timeGetTime ();
...//other code
timeEndPeriod ();
}

Or can I just call them like the following?

timeBeginPeriod ();
while(1){
t = timeGetTime ();
...//other code
}
timeEndPeriod ();

Whhich of the above two code snippets is correct?

Thanks
Dillon
s***@mvps.org
2008-12-27 04:23:19 UTC
Permalink
Post by Dillon Geo
Hi All,
The article in MSDN on timeBeginPeriod() and timeEndPeriod() says
"Call this function (timeBeginPeriod) immediately before using timer
services, and call the timeEndPeriod function immediately after you are
finished using the timer services."
I am confused by the above description. What do "the timer services"
include, all the functions associated with multimedia timer services, such
as the following?
        timeGetSystemTime, timeGetTime, timeGetDevCaps, timeKillEvent,
TimeProc, timeSetEvent
Yes - all the time functions in the multimedia group.
Post by Dillon Geo
I am also confused by "immediately before (after) using timer services". If
I have a loop that uses a timer service at each iteration, do I need to call
timeBeginPeriod and timeEndPeriod at each iter iteration, like the
following?
while(1){
    timeBeginPeriod ();
    t = timeGetTime ();
    ...//other code
    timeEndPeriod ();
}
Or can I just call them like the following?
timeBeginPeriod ();
while(1){
    t = timeGetTime ();
    ...//other code}
timeEndPeriod ();
Whhich of the above two code snippets is correct?
Thanks
Dillon
The second. It wouldn't make much sense to change the period just
before you (re)use it.

Loading...