I am trying to port a working "Form" application (medical DICOM worklist server) to service. The application is answering to multiple possibly concurrent connections, so i assume there must be separate thread for each existing connection. Connections (and threads) are closed after the requested data is sent.
For now my test service just echoes back text string received from client with addition of connection handle number. Problem: after 1-st client connection CPU usage of this service is 50%(probably because my CPU is Pentium D), after 2nd - 99% and remains 99% until service is stopped regardless that all clients are disconnected. After i added Sleep(10); into "while not Terminated do" loop of procedure TEchoThread.Execute; CPU usage dropped to 0, now it seems OK, but is this the right way to arrange service with threads for socket connections?

