Article View: borland.public.cppbuilder.internet.socket
Article #1900Re: TidSMTP-> Abort?
From: Remy Lebeau (TeamB)
Date: Tue, 26 Sep 2006 09:15
Date: Tue, 26 Sep 2006 09:15
29 lines
2042 bytes
2042 bytes
"Paw Suddergaard" <paw@top-house.dk> wrote in message
news:4517ed96$1@newsgroups.borland.com...
> I have an abort button that calls terminate:
>
> void __fastcall TEasyMail::IdThreadComponent1Terminate(
> TIdCustomThreadComponent *Sender)
> {
> // Does nothing: IdSMTP->Socket->Close();
> // Does nothing: IdSMTP->Disconnect();
> }
That is the completely wrong place to put that code. The thread is blocked
while Send() is running. The OnTerminate event is triggered when the thread
is terminated (thus its name). Calling Terminate() DOES NOT actually
terminate the thread immediately. All it does is sets the Terminated
property to true and nothing else. That signals to the thread that it
should terminate itself at its earliest convenience, which it can't do until
after Send() returns.
You need to call Disconnect() inside your button OnClick event directly, not
in the thread's OnTerminate event, in order to abort the sending. You
should also use DisconnectSocket() instead of Disconnect(), since you are
closing the connecting from a different thread than the one that established
the connection.
Gambit
Technical Details
Message-ID:
<4518f06c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.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:
<4517ed96$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,62a22a2ea734cdfd 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: <4517ed96$1@newsgroups.borland.com> Subject: Re: TidSMTP-> Abort? Date: Tue, 26 Sep 2006 02:15:45 -0700 Lines: 31 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: 69.169.4.232 Message-ID: <4518f06c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1159262316 69.169.4.232 (26 Sep 2006 02:18:36 -0700) Path: arc1-ca.pugleaf.net!g2news2.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