If you're on a windows platform, you might want to have a look at this page.
The methods you'd be using are SetTimer and KillTimer.