Hey everyone, Iam having trouble with a function i made that is basicly a timer. It takes the Start time of an event and a Trigger time. then checks if the Current time - the Start time is equal to the Trigger time.
When i debug the code the function apears to work fine. but when i run the app and the function is called the program freezes up for what seems to be the duration of the timer and then returns to normal,
Heres the function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void GApp_FPS::Timer(int StartTime, int TriggerTime)
{
TimerRun = true;
int Time = 0;
while(TimerRun == true)
{
Time = SDL_GetTicks() - StartTime;
if(Time > TriggerTime)
{
TimerRun = false;
break;
};
};
};
Why would you think it would behave any differently? The loop repeats over and over until Time > TriggerTime It's not freezing up - it's running through that loop over and over and over.
If you want other things to happen while that loop is being run through over and over and over, use threads.