Board index » delphi » CPU utilization while in IOHandler.WaitFor

CPU utilization while in IOHandler.WaitFor


2004-12-01 02:10:33 PM
delphi45
I'm using Indy 10 for an automation program I am writing.
With the TCP client component (not telnet, following a previous
recommendation from these newsgroups) I connect to a telnet server
(linux box), log in, and then issue commands with IOHandler.WriteLn(cmd)
and wait for the (well-known) prompt in a IOHandler.WaitFor call.
Everything works fine, except for the fact that the WaitFor call uses
100% of the CPU while it waits for the prompt. Most of the time this is
almost instantaneous, but for some commands to finish, this could take
several seconds. If you add the fact that my program is a multithreaded
app that simultaneously connects to 50+ boxes at the time, well, the CPU
can be "locked" for a while. Obviously, the program and computer aren't
really locket-out, although the GUI does slow down, but in any case,
nobody likes to see the task monitor's CPU bar shoot all the way to 100%
and remain there for extended periods of time.
Is there any way to prevent this? Normally I would use a sleep(1) call
wherever the code is looping waiting for data, but I can not do this in
this case. I tried doing it in the OnWork event handler, but that
doesn't seem to help.
Any ideas will be appreciated.
Idel.
 
 

Re:CPU utilization while in IOHandler.WaitFor

"Idel Lopez" <XXXX@XXXXX.COM>writes
Quote
Everything works fine, except for the fact that the WaitFor
call uses 100% of the CPU while it waits for the prompt.
<snip>
Is there any way to prevent this?
It is a bug in WaitFor(). There is no workaround, other than to not use
WaitFor() at all and implement your own waiting code manually until
WaitFor() can be fixed. It needs to be fixed anyway, WaitFor() can return
too much data from the InputBuffer, which is another long-standing bug that
needs fixing as well.
Gambit
 

Re:CPU utilization while in IOHandler.WaitFor

"Remy Lebeau \(TeamB\)" <XXXX@XXXXX.COM>writes:
Quote

It is a bug in WaitFor(). There is no workaround, other than to not use
WaitFor() at all and implement your own waiting code manually until
WaitFor() can be fixed. It needs to be fixed anyway, WaitFor() can return
too much data from the InputBuffer, which is another long-standing bug that
needs fixing as well.


Gambit


Ok, thanks for your reply. I will work on my own code then.