Sack Library Documentation
ContentsIndexReferenceHome
PreviousUpNext
sack::timers::AddTimerExx Function
C++
IMPORT_METHOD _32 AddTimerExx(_32 start, _32 frequency, TimerCallbackProc callback, PTRSZVAL user DBG_PASS);
#define AddTimerEx( s,f,c,u ) AddTimerExx( (s),(f),(c),(u) DBG_SRC )
#define AddTimer( f, c, u ) AddTimerExx( (f), (f), (c), (u) DBG_SRC)
Parameters 
Description 
_32 start 
how long in milliseconds until the timer starts. Can be 0 and timer will fire at the next opportunity. 
_32 frequency 
how long the delay is between event invocations, in milliseconds. 
TimerCallbackProc callback 
user routine to call when the timer's delay expires. 
user 
user data to pass to the callback when it is invoked. 

a 32 bit ID that identifies the timer for this application.

Adds a new periodic timer. From now, until the timer is removed with RemoveTimer, it will call the timer procedure at the specified frequency of milliseconds. The delay until the first time the timer fires can be specified independant of frequency. If it is not specified, the first time the timer will get invoked is at +1 frequency from now.

if a timer is dispatched and needs to wait - please link with idlelib, and call Idle. this will allow other timers to fire on schedule. The timer that is waiting is not in the list of timers to process.

First some setup valid for all timer creations...

void CPROC TimerProc( PTRSZVAL user_data )
{
    // user_data of the timer is the 'user' parameter passed to AddTimer(Exx)
}

you might want to save this for something like RescheduleTimer

_32 timer_id;
   
   

Create a simple timer, it will fire at 250 milliseconds from now, and again every 250 milliseconds from the time it starts.

timer_id = AddTimer( 250, TimerProc, 0 );

 

Create a timer that fires immediately, and 732 milliseconds after, passing some value 1234 as user data...

timer_id = AddTimerEx( 0, 732, TimerProc, 1234 );
   
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at support@toolsfactory.com.
Copyright (c) 2000+. All rights reserved.
What do you think about this topic? Send feedback!