Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 115675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:03:26+00:00 2026-05-11T03:03:26+00:00

I use Indy 9 with Delphi 5. In my application I want to communicate

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:03:27+00:00Added an answer on May 11, 2026 at 3:03 am

    The problem you have is because you’re receiving the UDP data in the GUI thread, but want to process the data in another thread.

    The real problem is that your trying to use a asynchronous component in a blocking way. The better solution would be to use a real blocking UDP communication library such as synapse. Then it’s very easy to just wait for new data to receive in your thread.

    You could just write:

    while not Terminated do begin   BytesRead := FSocker.RecvBufferEx(@(Buffer[0]), BufferSize, Timeout);   if (BytesRead = 0) then   begin     // continue or exit if the receiving Failed     case FSocket.LastError of       0, WSAETIMEDOUT: Continue;       WSAECONNRESET, WSAENETRESET,         WSAENOTCONN, WSAECONNABORTED,         WSAENETDOWN:         begin           CloseConnection;           Exit;         end;     else       CloseConnection;       Exit;     end;       end;   // process the data in the buffer end; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Delphi application with a Indy TCPServer and TCPClient. I use the
I want to upgrade my application from Indy 9 to 10 with Delphi 2007.
I want to upgrade my application from Indy 9 to 10 with Delphi 2007.
I have a Delphi 6 application that uses an Indy TIdTCPClient instance to communicate
I'm just starting to learn how to use the Indy 10 components in Delphi
I am using the indy components to implement emails in a delphi application. I
There's a web services I want to call in my application, I can use
We have an application server developed with Delphi 2010 and Indy 10. This server
What is the normal way people writing network code in Delphi use Windows-style overlapped
I use Indy's TIdTCPServer (D2009, Indy 10) to communicate with client applications. In the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.