<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2523" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>You will find CPU usage goes way down if you slow
the loop down using sleep(). Even Sleep(10) should significantly
reduce CPU usage. The higher the better of course.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Ross.</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=phil@tumonz.co.nz href="mailto:phil@tumonz.co.nz">Phil Middlemiss</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi
List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, October 15, 2004 11:16
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [DUG] Thread processes</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>I have a thread that sits in the background
waiting for input from a COM port. the execute method simple has these
two lines:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> while not Terminated
do<BR> Application.ProcessMessages;<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>The problem with this is that the processor usage
is very high, even if the thread is doing nothing but sitting there calling
processmessages.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The main application thread doesn't have this
problem, yet it also has a message handling routine. </FONT><FONT face=Arial
size=2>Is there a way to avoid this problem in threads?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2>Phil.</DIV></FONT>
<P>
<HR>
<P></P>_______________________________________________<BR>Delphi mailing
list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR></BLOCKQUOTE></BODY></HTML>