FreeThread() to close OS handle?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

FreeThread() to close OS handle?

Post by dige »

I've got a hint from Danilo, that every thread create a thread object which remains in the system until the thread has terminated and all handles to it have been closed through a call to CloseHandle_().
(German pb board: http://www.purebasic.fr/german/viewtopic.php?t=16950 )
If you dont close it with CloseHandle_ (ThreadID), it still stays open, lacks memory und increase the user objects counter.

Another thing is, you can get the exit code from the thread via that handle:
GetExitCodeThread(
HANDLE hThread, // handle to the thread
LPDWORD lpExitCode // address to receive termination status
);
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I already answered on IRC, but i will put it here as well: there is no leak, as every CreateThread() has a cleanup routine which check for finished threads and properly close their handle.
Post Reply