Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

implementing timing device in loop

Status
Not open for further replies.

sph147

Programmer
May 17, 2004
19
0
0
US
What I really need is a way to have a loop run for one hour, then reset and begin again. How would I use some kind of timing device and what type of files do I need to include? This portion of my program is intended for windows. Any help or finger points in a right direction or website would be greatly appreciated. Thanks.
 
How about using SetTimer() with a specification of 60000? That amounts to 60 seconds. Then in your WM_TIMER handler increment your variable by 1. When your variable reaches 60, it has been one hour. There are other functions such as QueryPerformanceCounter() and GetTickCount() which are supposed to be more accurate, but shouldn't be worried about unless tenths of a second over an hour's duration are that important.

bdiamond
 
You could also use a thread, but if you are using MFC, it would probably be easier to use a timer as bdiamond suggests.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top