Article View: borland.public.cppbuilder.nativeapi
Article #12465Re: Killing off a crashed thread
From: Remy Lebeau (TeamB)
Date: Thu, 04 Dec 2003 18:25
Date: Thu, 04 Dec 2003 18:25
19 lines
1764 bytes
1764 bytes
"bladder" <bladder@lardyboys.com> wrote in message news:3fcf0500$1@newsgroups.borland.com... > What I'd like to know is the recommended way that a thread > can terminate another thread( even if the thread is running ) and > what cleaning up the terminating thread should perform? Assuming that you are using TThread, the safest way is to just call the thread's Terminate() method and then have the thread check its Terminated property periodically so that it can return from its Execute() method gracefully. Or if the thread has a message queue, post a WM_QUIT message via PostThreadMessage() so that the queue is exited and Execute() can return. Otherwise, the only other way is via the Win32 API TerminateThread() function, however that is a brute-force termination that won't allow the thread to do any kind of cleanup at all. Gambit
Technical Details
Message-ID:
<3fcf7af5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fcf0500$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f3d1051f853af8a9 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-04 10:40:38 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fcf0500$1@newsgroups.borland.com> Subject: Re: Killing off a crashed thread Date: Thu, 4 Dec 2003 10:25:03 -0800 Lines: 21 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.23.78.224 Message-ID: <3fcf7af5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1070562037 67.23.78.224 (4 Dec 2003 10:20:37 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail