This site is no longer active and is available for archival purposes only. Registration and login is disabled.

100% CPU Usage normal?


100% CPU Usage normal?

Postby Avatar » Sep 10, 2001 @ 9:03pm

Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: 100% CPU Usage normal?

Postby Dan East » Sep 10, 2001 @ 11:18pm

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: 100% CPU Usage normal?

Postby Dan East » Sep 10, 2001 @ 11:21pm

To make your app fullscreen, and hide the SIP button, etc., do the following whenever you receive a WM_ACTIVATE message when your app is gaining activation:<br>[fixed]<br>SHFullScreen(hWnd, SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON);<br>MoveWindow(hWnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), TRUE);<br>[/fixed]<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: 100% CPU Usage normal?

Postby Digby » Sep 11, 2001 @ 1:55am

You shouldn't need the Sleep() call to yield.  GetMessage() will block when there are no more messages to process and the OS scheduler should switch to another process if one is waiting to run.  You might have something screwed up in your WndProc, or if you have a timer running that is generating messages GetMessage will never block.<br><br>How are you determining the current CPU usage?<br><br>
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: 100% CPU Usage normal?

Postby Avatar » Sep 13, 2001 @ 2:26am

Thanks for the help.<br>First problem (100% CPU) was fixed by remarking of the empty 'case WM_PAINT' (well, it's empty @ the moment), though Sleep(x) also worked. Programmers take notice - never leave empty WM_PAINT case! Or you will be wasting CPU without reason.<br>Second question (full screen) was fixed w/ those 2 API calls. Thanks again.<br><br>BTW, any idea as to why an empty case statement (and yes, it did have break in it) would cause the CPU to go to 100%?<br><br>And as to how I measured the CPU usage - task manager on win2k ;)
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: 100% CPU Usage normal?

Postby Dan East » Sep 13, 2001 @ 10:08am

You must call BeginPaint and EndPaint if you handle a WM_PAINT message. Windows will send your app a WM_PAINT if your window's update region is not empty (which indicates which portions of your window need to be redrawn). BeginPaint / EndPaint clears the update region, so Windows will not call WM_PAINT again unless part of the window needs to be redrawn, or you explicitly call RedrawWindow, etc. You can also use ValidateRect to validate your Window's entire client area to prevent more WM_PAINT messages. However, if you don't ever paint in WM_PAINT, then don't even handle the message. <br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: 100% CPU Usage normal?

Postby RICoder » Sep 13, 2001 @ 5:30pm

Have you considered peekmessage instead of getmessage?
<iframe src="http://gamercard.xbox.com/RICoder.card" scrolling="no" frameBorder="0" height="140" width="204">RICoder</iframe>
User avatar
RICoder
FOX News Correspondent
 
Posts: 3948
Joined: Jul 10, 2001 @ 1:48pm
Location: the matrix has me


Re: 100% CPU Usage normal?

Postby Digby » Sep 13, 2001 @ 7:21pm

>>And as to how I measured the CPU usage - task manager on win2k  <br><br>Duh.  I knew about that.  I was under the impression that you were running your app on a Pocket PC and had some way to get the CPU usage.<br><br>
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: 100% CPU Usage normal?

Postby Avatar » Sep 13, 2001 @ 7:54pm

Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: 100% CPU Usage normal?

Postby Avatar » Sep 13, 2001 @ 7:56pm

Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: 100% CPU Usage normal?

Postby Moose or Chuck » Sep 13, 2001 @ 8:21pm

Moose or Chuck
 


Re: 100% CPU Usage normal?

Postby Digby » Sep 13, 2001 @ 11:57pm

Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: 100% CPU Usage normal?

Postby Dan East » Sep 14, 2001 @ 10:51am

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron