Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 4th, 2006, 11:29 AM   #1
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
way to make a function execute at time 'x'

Is there a way to make a function's execution wait till a specific system time? example. I want the end user to choose from 3-4 times (time of day) to make a function run (shutdown or restart computer). The fourth choice maybe 1.5 hours from the time that the user would be prompted to make the choice. Is there a way to make the program check the current system time often enough to make the program execute properly, but not hog up a ton of CPU cycles?

The best solution I have come up with would be done by making the program sleep for approx. 30 seconds then run an IF statement to see if the user defined time = the current system time (+/- 30 sec) and loop until that value is reached.

Would this work sufficiently in your opinion, or is there another way? To my knowledge, Sleep uses little to no CPU time. If this is the case, then in theory, my example will use very little CPU resources while running the time check loop. So I guess my last question is. Can you actually designate a time and have the program reference that to the current system time then execute a function if the two are equal (in this case equal +/- 30 sec.)?

If I was not descriptive enough, please let me know and I will try and explain better.

Thanks for the help,
-BB98
__________________
Learning to use C++ and loving every minute of it.
badbasser98 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC