Quote:
Originally posted by wgan
sorry, i didnt explain it clearly, i mean if i do a very busy job, such as drawing random rectangles just like what Charles Petzold did in his book.
///////////////////////////
while (TRUE)
{
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break ;
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
else
DrawRectangle (hwnd) ;
}
//////////////////////////
it does use 100%CPU, even if i add thread, it is still 100%, add a Sleep(), it will be slowww....etc that i described them in the first post...things like that, very busy whitout thread or very slow with Sleep().
I want my program to adjust the CPU usage automatically by using thread technology, can I?
What do you mean by "add thread"? You're drawing rectangles as fast as you can without stopping or waiting, a simple timer (like draw every 100ms) will fix this problem. Like: