Article View: borland.public.cppbuilder.internet.socket
Article #2545Re: how to write receiving thread correctly (Indy)
From: Remy Lebeau (TeamB)
Date: Fri, 24 Mar 2006 09:07
Date: Fri, 24 Mar 2006 09:07
19 lines
1711 bytes
1711 bytes
"Boris Epel" <boep777@yahoo.com> wrote in message news:44239df4$1@newsgroups.borland.com... > the problem is that this code is obviously block the > thread when I want to shutdown application Simply disconnect the socket from the main thread. Any futher socket operations on the socket will cause the reading code to throw an exception, which will then break your while() loop so the thread can terminate. Also, your thread code should be checking the Terminated property before performing any lengthy operations, and before calling Synchronize() (if you use that). Also, the main thread should call the thread's Terminate() method before closing the socket, and then call the thread's WaitFor() method to wait for the thread to fully terminate itself. Gambit
Technical Details
Message-ID:
<4423b6ce$3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44239df4$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,781e876beb7d3f81 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <44239df4$1@newsgroups.borland.com> Subject: Re: how to write receiving thread correctly (Indy) Date: Fri, 24 Mar 2006 01:07:09 -0800 Lines: 21 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <4423b6ce$3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1143191246 68.69.17.41 (24 Mar 2006 01:07:26 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail