I use Indy 9 with Delphi 5. In my application I want to communicate with a network device via UDP. So I use UDPServer comp. in a class which is derived from TThread. When I write similar to the following code then CPU usage is 100%.
in the thread :
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 OnUDPRead event :
try
// Processing the data here
except
PostThreadMessage(ThreadId, WM_UDPMSG, 0, 0);
end;
When I use Sleep function in the while-do loop or in OnUDPRead event there is no change. Still the CPU usage is 100%.
My thread priority is Normal.
How can I solve my problem?