infinite loop causing program to crash

I got win32 application, that runs a infinite for loop, which increment a value inside the loop. the problem am having is that my application become unresponsive and uses alot of CPU when compiled.

my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
case IDM_ROTATION:
			
			for(int i = 0; i < 4; i++)
			{

				i = 0;

				rotation += rotationIncrement;
				InvalidateRect(hWnd, NULL, TRUE);
				UpdateWindow(hWnd);
			}

			break;


How can i fix this?, I just want a loop or timer that increment my rotation variable every second.
Last edited on
Then use a Windows timer rather than a for loop. That is a quite poor way to go about it in my opinion (what you have shown).

If you use a timer, you can either have the message sent to your Window Procedure, or have it directed to a callback for which you've specified a name. Check out WM_TIMER and SetTimer().
Please delete line 6, this causes your infinite loop.
Thanks @freddie1 and @modoran used the windows timer and it worked.
every time the loop runs, "I's" value is set to zero so it will never be anything other than zero. Delete that.
Topic archived. No new replies allowed.