-
Help Request
Hi all,
how is it possible in c++, that i can call a method after 1 hour
for example in my case i have huge amount of data,
i can not check all at once
so i need to call the functuion automatically after 1 hour
kindly give me some code example if possible
-
Re: Help Request
sleep() can be used to wait. Is that what you want?
Please elaborate your requirement.
Ganesh
-
Re: Help Request
no sleep or wait use too much system resources as inside sleep loops use for delays
i need to call a function
called after a specific time
e . g after 1 hour
-
Re: Help Request
what OS are you using / compiler ?
both the sleep and wait I'm familiar with use virtually no CPU resources - and no they don't just loop for delay, unless they are incredibly naive implementations on a particular compiler or os.
There are also timers, but again this is dependent on OS.
-
Re: Help Request
I'm guessing you have large program that is always doing something, and has a main loop that only breaks on some particular user input?
I'd suggest just look into the data structures and functions in <time.h>.
Use a variable in your main loop called lastRunTimeFunctionWhatever, initiallized to zero. Check the current system time using <time.h> once per main loop, compare it to that variable, if more than 60 minutes have passed, set the variable to the current system time, then execute your function.
-
Re: Help Request
You could use a timer.
"in my case i have huge amount of data,
i can not check all at once
so i need to call the functuion automatically after 1 hour" doesn't make sense to me. Can you explain the problem in more detail.