I want a function F() to be called every 60 seconds.
How can i do it?
Printable View
I want a function F() to be called every 60 seconds.
How can i do it?
Depends on what environment you are using. Which OS would be a good start.
--
Mats
Windows XP
Is it a console or windowed application? In a windowed application, you use SetTimer and then use the WM_TIMER or [in MFC] OnTimer() to process your timer.
In console, it sort of depends on what else you are doing, since it's not event-driven in the way that a Windows app is, so you would need to find some other solution. There are several, but it would be good if you could explain what your application is doing when you want to call a function every sixty seconds. Options include using Sleep() or using multiple threads.
--
Mats
Example of matsp suggestion
Not the best example but its more or less what he was on about. The trick is implementing this sort of algorithm into your codeCode:for ( ;; )
{
if ( flag > 3 )
{
break;
}
Sleep(60000);
F();
flag++;
}