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.
for(int i = 0; i < 4; i++)
i = 0;
rotation += rotationIncrement;
InvalidateRect(hWnd, NULL, TRUE);
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.