A timed loop
-
Hey,,, I have a fer function that wait for input for a while... at the moment... I code it simple like this... for(i=0; i<50000000; i++){ //waiting for input } As Processes inside the loop are changing, the loop takes longer and shorter amounts of time to complete.. 3sec to 50sec. what the easiest way to set up a timed loop that loops the same amount of time every time? Example: While ( time < 10Seconds ){ //wait for input }
-
Hey,,, I have a fer function that wait for input for a while... at the moment... I code it simple like this... for(i=0; i<50000000; i++){ //waiting for input } As Processes inside the loop are changing, the loop takes longer and shorter amounts of time to complete.. 3sec to 50sec. what the easiest way to set up a timed loop that loops the same amount of time every time? Example: While ( time < 10Seconds ){ //wait for input }
-
Hi!!, u can put a counter inside the loop that increments to a particular no every time e.g. int count=0 for(i=1;i<=50000000;i++) count = count+i
Later I'll be adding a "wait time option" so I gotta go by time... Just looking for the easiest way to code in a timer into a loop.
-
Later I'll be adding a "wait time option" so I gotta go by time... Just looking for the easiest way to code in a timer into a loop.
Ok.. I think I figured out the easiest way :) DWORD dwStart = GetTickCount(); while( GetTickCount() - dwStart < WAITTIME ){ //loop for WAITTIME milliseconds }
-
Ok.. I think I figured out the easiest way :) DWORD dwStart = GetTickCount(); while( GetTickCount() - dwStart < WAITTIME ){ //loop for WAITTIME milliseconds }