-
May 8th, 2009, 02:10 AM
#1
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
-
May 8th, 2009, 02:19 AM
#2
Re: Help Request
sleep() can be used to wait. Is that what you want?
Please elaborate your requirement.
Ganesh
-
May 8th, 2009, 02:38 AM
#3
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
-
May 8th, 2009, 06:12 AM
#4
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.
If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).
-
May 8th, 2009, 11:52 AM
#5
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.
-
May 8th, 2009, 02:41 PM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|