|
-
April 20th, 1999, 12:41 PM
#1
_endthreadex
The documentation for _endthreadex stipulates that you must call ::CloseHandle()yourself when your thread terminates, but it is not clear to me how the needed handle is obtained. _beginthreadex returns an unsigned long which the documentation describes as a "handle" to the thread, but Winnt.h typedefs a HANDLE as a void pointer -- not an unsigned long. Needless to say, I'm leery of blindly casting an unsigned long to a void*. Does anyone have any ideas about this?
Thanks
Doug Brower
-
December 1st, 1999, 11:39 AM
#2
Re: _endthreadex
If I can remember correctly if the thread returns you do not need to call the end function. If the thread runs forever or you just need to end it the end function has to be called from within the thread so the best thing to do is send that thread a message telling it to kill itself. Hope this helps. P.S. there are several ways to send this message using a global class is one.
-
December 1st, 1999, 11:41 AM
#3
Re: _endthreadex
You can cast the unsigned long returned by _beginthreadex() and what you get is a HANDLE. You can then use it in _endthreadex().
HANDLE hThread = (HANDLE)_beginthreadex(...);
_endthreadex(hThread);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|