Link to home
Start Free TrialLog in
Avatar of lenzge
lenzge

asked on

Timer feature...

Hi everyone, I'm having one question and hope can find out solutio here. I need to implement a feature just like Timer control in VB. When each interval time is achieved, a function will be called to carry out some tasks automatically, without supervision of user. Basically it is similiar to tasks scheduling. Any idea on how to do this? Thanks!
Avatar of sunnycoder
sunnycoder
Flag of India image

Hi lenzge,

use alarm and signals

alarm(10);

will set an alarm for 10 seconds ... after 10 seconds have elapsed, SIGALRM will be raised ... you will have to set up a signal handler for handling SIGALRM ...

this signal handler will be invoked each time SIGALRM signal is encountered

look into help pages for sigaction signal and alarm

Cheers!
Sunny:o)
Check out the documentation about SetTimer or the whole Timer API.
e.g from here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers.asp

Regards
Friedrich
Avatar of lenzge
lenzge

ASKER

It seems that both suggestions are having same logic: using signal to fire actions. However I'm still not clear about the syntax on doing it. For Sunny, I can't find the topic on sigaction from MSDN library; for Friedrich, the sample code in provided link is incomplete, therefore it cannot been compiled and I don't know what is missing. Can you try to post a simple sample here? Thanks to both of you.
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

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 lenzge

ASKER

It is working. Thanks!
Avatar of lenzge

ASKER

It is working. Thanks!