![]() It sounds like you want a program to turn something off under a given set of conditions. I think you may want to step back and approach the problem a bit differently. ![]() I want to write it from scratch as it's a part of a personal project I've been working on.Ī lot of these answers include something known as "busy waiting." Checking the time over and over again in a while() loop is a bad idea 99% of the time. I input the time manually so I need a timer. I've created a program that runs in the background and powers off the system if it's idle for a certain amount of time, it also checks for the battery life on a specific system and goes to stand by mode if the system has been running on battery for a while. OK, it seems that this caused some confusion so I'm going to try to explain what I have done so far. The nature of the program: The program counts power time and battery time on systems. I dont want to use the unsleep or sleep function as I'm trying to write everything from scratch. The program works on a set of servers both Linux and Windows, so it's a multiplatform environment. I'm looking for the simplest way to write a timer. The program worked as I wanted it to, but consumed too much system resources. I used the for loop as a counter and the do-while loop as a comparison for "end of time". ![]() What is the simplest way to write a timer, say in C/C++? Previously I used a for loop and a do-while loop. What is the simplest way to write a timer in C/C++?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |