Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

100% CPU Utilization poll mouse 1

Status
Not open for further replies.

griv

Technical User
Jan 31, 2002
10
AU
Hi,

I have an app that has been crudely converted from DOS basic to Windows. Thh program polls for mouse input, while a user moves an item on the screen.

The program uses 100% of the CPU while this screen is displayed. If you open a file or select another area of the program the CPU drops to only a few percent. It seems to be in this area of the program that is using dos routines to poll for the mouse.

The program works fine even with 100% utilization. It can be minimized and other programs run OK as well. There is no obvious slowdown except for a certain screensaver that does not refresh as quickly when the program is running. I have dismissed this for the moment as it is just a sceensaver.

Is there an issue with a program that consumes a high number of clock cycles but all other program work fine? Is there a caveat emptor that I should be looking for?

I have searched the web and can't see anything specific. I have been asked by a few users why the cpu is so high but since everything runs fine, I am assuming that the Operating System is taking care of the time slicing.

Thanks for any advice.

 
VB is basically event-driven, so you (generally) don't need to poll for the commonplace actions. Your form has a MouseMove event which is fired on a MouseMove. Try using the intrinsic events rather than polling

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Do a kernel sleep in your loop and all will be good. about 100 milliseconds should do it.
 
Bingo!

Thanks heaps for this azrobert. It has been driving me nuts for ages. I'm glad I ased the question.

Griv.
 
Why does this work? Does it give the OS a chance to service other applications? It is great knowing the fix but I'd like to find out why.

Thanks.
 
It puts your application to sleep. Frankly, unless this is exactly what you want to do, I wouldn't advise it as a solution
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top