Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to repeat a process after a given time interval.

Status
Not open for further replies.

gurpreetpall

Programmer
Apr 18, 2002
1
IN
how to repeat a process after a given time interval
 
See FAQ - thread205-79777
there's lots of examples use 'sleep' as a keyword for your search Dickie Bird
db@dickiebird.freeserve.co.uk
 
If your programming for windows, you can also use the SetTimer() function.
This is the prototype found in the MSDN library:

UINT_PTR SetTimer(
HWND hWnd, // handle to window
UINT_PTR nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // timer procedure
);

It is declared in the Winuser.h (include windows.h) and you must provide your own callback function which will be called by windows when its time. The prototype of the callback is:

VOID CALLBACK TimerProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_TIMER message
UINT_PTR idEvent, // timer identifier
DWORD dwTime // current system time
);

Although the prototype implies you need to supply a handle to a window, this is not necessary and you can set it to NULL. The difference of timing this way is that your program will not be halted the way a function like Sleep() does, and your program can continue doing its tasks until it is interrupted by the timed out callback, after which your program can continue its tasks. (There is also the Beep() function, which does simply what its names says: it gives a beep. And I've use it to experiment with SetTimer(); it works nice and easy =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top