Click here to Skip to main content
16,010,553 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how do I make edit boxes appear during run-time? Pin
Sprudling10-Feb-02 11:03
Sprudling10-Feb-02 11:03 
AnswerRe: how do I make edit boxes appear during run-time? Pin
Nish Nishant10-Feb-02 13:25
sitebuilderNish Nishant10-Feb-02 13:25 
GeneralRe: how do I make edit boxes appear during run-time? Pin
Jon Hulatt10-Feb-02 22:36
Jon Hulatt10-Feb-02 22:36 
Generalreturning prematurely from blocked function Pin
10-Feb-02 2:21
suss10-Feb-02 2:21 
GeneralRe: returning prematurely from blocked function Pin
Tim Deveaux10-Feb-02 3:33
Tim Deveaux10-Feb-02 3:33 
GeneralRe: returning prematurely from blocked function Pin
10-Feb-02 12:04
suss10-Feb-02 12:04 
GeneralRe: returning prematurely from blocked function Pin
Tim Deveaux10-Feb-02 12:32
Tim Deveaux10-Feb-02 12:32 
GeneralRe: returning prematurely from blocked function Pin
Tim Smith10-Feb-02 13:21
Tim Smith10-Feb-02 13:21 
TerminateThread is a VERY agressive function and I would aviod using it AT ALL COSTS.


TerminateThread is used to cause a thread to exit. When this occurs, the target thread has no chance to execute any user-mode code and its initial stack is not deallocated. DLLs attached to the thread are not notified that the thread is terminating.

TerminateThread is a dangerous function that should only be used in the most extreme cases. You should call TerminateThread only if you know exactly what the target thread is doing, and you control all of the code that the target thread could possibly be running at the time of the termination. For example, TerminateThread can result in the following problems:

If the target thread owns a critical section, the critical section will not be released.

If the target thread is allocating memory from the heap, the heap lock will not be released.

If the target thread is executing certain kernel32 calls when it is terminated, the kernel32 state for the thread's process could be inconsistent.

If the target thread is manipulating the global state of a shared DLL, the state of the DLL could be destroyed, affecting other users of the DLL.

A thread cannot protect itself against TerminateThread, other than by controlling access to its handles. The thread handle returned by the CreateThread and CreateProcess functions has THREAD_TERMINATE access, so any caller holding one of these handles can terminate your thread.

If the target thread is the last thread of a process when this function is called, the thread's process is also terminated.

The state of the thread object becomes signaled, releasing any other threads that had been waiting for the thread to terminate. The thread's termination status changes from STILL_ACTIVE to the value of the dwExitCode parameter.

Terminating a thread does not necessarily remove the thread object from the system. A thread object is deleted when the last thread handle is closed.


As you can see, using TerminateThread is just asking for problems.



Tim Smith
Descartes Systems Sciences, Inc.
GeneralRe: returning prematurely from blocked function Pin
567890123410-Feb-02 3:45
567890123410-Feb-02 3:45 
GeneralRe: returning prematurely from blocked function Pin
10-Feb-02 12:12
suss10-Feb-02 12:12 
GeneralQuestion: Dynamic CEdit Window with Shortcut keys Pin
Kevin Cao9-Feb-02 23:05
Kevin Cao9-Feb-02 23:05 
GeneralRe: Question: Dynamic CEdit Window with Shortcut keys Pin
Christian Graus9-Feb-02 23:25
protectorChristian Graus9-Feb-02 23:25 
GeneralAgain GDI+ but diffrenet question Pin
Mazdak9-Feb-02 22:40
Mazdak9-Feb-02 22:40 
GeneralRe: Again GDI+ but diffrenet question Pin
Christian Graus9-Feb-02 22:57
protectorChristian Graus9-Feb-02 22:57 
GeneralFloating Point Variables Pin
9-Feb-02 22:10
suss9-Feb-02 22:10 
GeneralRe: Floating Point Variables Pin
Christian Graus9-Feb-02 22:40
protectorChristian Graus9-Feb-02 22:40 
GeneralRe: Floating Point Variables Pin
alex.barylski9-Feb-02 22:48
alex.barylski9-Feb-02 22:48 
GeneralRe: Floating Point Variables Pin
Tim Deveaux10-Feb-02 3:18
Tim Deveaux10-Feb-02 3:18 
GeneralRe: Floating Point Variables Pin
Tim Smith10-Feb-02 3:25
Tim Smith10-Feb-02 3:25 
QuestionHeap, stack? Pin
Jasmyn9-Feb-02 22:06
Jasmyn9-Feb-02 22:06 
AnswerRe: Heap, stack? Pin
alex.barylski9-Feb-02 22:25
alex.barylski9-Feb-02 22:25 
GeneralRe: Heap, stack? Pin
Jasmyn9-Feb-02 23:04
Jasmyn9-Feb-02 23:04 
GeneralRe: Heap, stack? Pin
alex.barylski9-Feb-02 23:34
alex.barylski9-Feb-02 23:34 
GeneralRe: Heap, stack? Pin
Nish Nishant9-Feb-02 23:13
sitebuilderNish Nishant9-Feb-02 23:13 
GeneralRe: Heap, stack? Pin
alex.barylski9-Feb-02 23:31
alex.barylski9-Feb-02 23:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.