[C++] BeginPaint takes too much CPU time - any alternative?

Started by
9 comments, last by iMalc 16 years, 1 month ago
Quote:Original post by goodie
Thanks everyone for answers - I changed InvalidateRect TRUE to FALSE, but there was no change, so i guess i had a tight main loop, because when i put Sleep(5) in the loop the time taken decreases to 0-1%, which seems normal to me. Is the problem of tight loops usually solved with Sleep() or is there another approach?
Ah, you didn't say CPU usage was up to 100%.
You had what is called a "busy loop". Some form of yielding is required to reduce the CPU usage back to something sensible. Sleep(1) will do that just fine..
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement