Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

OverGround

My app takes 100% of the cpu cycle, HELP

This topic is 5217 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently wrote a program in visual C++ 6, all the program does is check the localTime against a text file of times and if they are equal executes a program. This is the same thing as the MS. Scheduler program. My question is, how come my app takes up 100% of the cpu cycles. All of the other game programs i have written do this and that is fine for a game, but for a windows app I dont want to take that many cycles just to check the loacl time. Why does the windows code take up 100% of the cpu cycles??

Share this post


Link to post
Share on other sites
Advertisement
because you do nothing but loop and loop and loop and loop?

what did you expect to happen? the computer magically divines that it can stop processing in THIS thread for awhile because nothings changed in what its checking over and over and over again?

I suggest reading the file, calculating the time until the next time it has to do something, and then sleeping for that amount of time.

Share this post


Link to post
Share on other sites
An even better solution to this is to use events and threading to accompish the same thing. look up the windows multimedia library to find a cool accurate timer function that you can have callback your program at certain times.

--------------------------------------

It took me long enough, but now I am finally 16. Yay! Sorta funny, but I am probably the only person on earth who wrote a 3D driving game prior to actually driving .

Share this post


Link to post
Share on other sites
Try using the Win32 Sleep() function at the end of the loop, to allow some time to pass before running the code inside the loop again. Note Sleep() takes a time parameter in milliseconds (1/1000 of a second).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!