Program freezing on loop

Hey everyone. I've ran into a problem. I'm working on a trainer for a game, actually once I figure out this loop problem it'll be finished, and when I use a loop to create the infinite ammo the program itself freezes up, but it still works in game as intended. Here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
bool timerstate = false;
int lapse = clock();

if (cb1->Checked)
{
   timerstate = true;
				 
   while(timerstate)
      {
         if(clock() - lapse > 500)
            {
                 //memory coding ect..
                 lapse = clock();
					 
             } 
				 
        }
					 
 }
else
{
      timerstate = false;
}

I tried it at 5000(5 seconds) to make sure it wasn't from the loop speed, but it freezes with that too. I've tried using just while(1), for(,,), and i decided to use the clock() and all end with the same result. I get the infinite ammo effect, but the program freezes when I check the checkbox. Also when click on the checkbox it actually freezes before the checkebox can even be ticked. Any ideas? Thanks
Topic archived. No new replies allowed.