Jammer1224
asked on
In loop time checking
Everything is in the code :)
int main() {
while (1) {
OccoursEveryLoopRun();
ThisShouldOccourOnlyOnceEv ery10Minut es();
Sleep(x);
}
return 0;
}
int main() {
while (1) {
OccoursEveryLoopRun();
ThisShouldOccourOnlyOnceEv
Sleep(x);
}
return 0;
}
You can just use the TTimer component.
As Jase-Coder suggests, drop a TTimer component onto your application. Set Interval = 1000 (1 second). Then just code to it.
TMainForm::TTimer1Timer ()
{
OccursEveryLoopRun ();
if ((Counter % 600) == 0)
thisShouldOccurOnlyOnceEve
}
Good Luck,
Kent
Opps.
Increment Counter before exiting.
Increment Counter before exiting.
You could use common C/C++ time functions ( http://www.cplusplus.com/reference/clibrary/ctime/ ) and then check, within the while loop:
(Use 600 is counting time as seconds, if in millisecs it would be 600.000)
if((currenttime-lastevent) >=600){
lastevent=currenttime;
do what you have to do
}
(Use 600 is counting time as seconds, if in millisecs it would be 600.000)
if((currenttime-lastevent)
lastevent=currenttime;
do what you have to do
}
ASKER
spiglerg if you would write a full example with the ctime object that would be the best for me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.