Link to home
Start Free TrialLog in
Avatar of mvu
mvu

asked on

How to set a countdown timer

Hi,

I'd need to know how to set a timer in C/C++, so that at the end of the given time, it executes what i want it to do.
But in the meantime of that happening, i would like the program to execute other tasks.
This would be like a separate process.

thanx for any suggestions and help
ASKER CERTIFIED SOLUTION
Avatar of thresher_shark
thresher_shark

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thresher_shark
thresher_shark

Oh, one last thing I need to add, the function that you want the timer function to call must be in this form:

VOID CALLBACK TimerProc( HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message

UINT idEvent, // timer identifier
 
DWORD dwTime // current system time
);

Try looking up TimerProc in the help file for more information on this function.
Avatar of mvu

ASKER

Thanx for the response.  How can I get to be in Seconds or hours, instead of milliseconds?

so the way it runs would be something like this:

SetTimer(NULL,1,timeout in msecs,"name of function i like to run at end of timeout");


Avatar of mvu

ASKER

I did not see your second comment.  I am not sure i understand, the function i need to run must be in the TimerProc form....

Can you give an example?
Avatar of mvu

ASKER

Thanx! I am all set for what I needed to do, using timerproc and settimer.  
Glad I could help :-)