I am using Indy 9 with Delphi 5. In my application, I want to communicate with a network device via UDP. Therefore, I am using the UDPServer comp. in a class that is derived from TThread. When I write similarly to the following code, then the CPU usage is 100%.
in the stream:
while not terminated do begin
if GetMessage(Msg, 0, 0, 0) then begin
if Msg.message = WM_UDPMSG then
Break
else
DispatchMessage(Msg);
end;
end;
and the OnUDPRead event:
try
except
PostThreadMessage(ThreadId, WM_UDPMSG, 0, 0);
end;
When I use the Sleep function in a while-do loop or in the OnUDPRead event, there is no change. However, CPU utilization is 100%.
My thread priority is Normal.
How can I solve my problem?
source
share