SuspendThread & TerminateThread
-
I find the VS help to be a little vague on this method, does SuspendThread halt execution of a thread -immediately-? And what if the thread contains some no-user-mode code? Can I use it to decently halt a thread before calling TerminateThread to brutally kill it? PS: I'm using TerminateThread because in one of my threads I'm calling into a function of a third-party lib (out of my control) that sometimes hangs. TerminateThread seems the only option left to stop the hanging (now threaded) function and retain control over application execution.
-
I find the VS help to be a little vague on this method, does SuspendThread halt execution of a thread -immediately-? And what if the thread contains some no-user-mode code? Can I use it to decently halt a thread before calling TerminateThread to brutally kill it? PS: I'm using TerminateThread because in one of my threads I'm calling into a function of a third-party lib (out of my control) that sometimes hangs. TerminateThread seems the only option left to stop the hanging (now threaded) function and retain control over application execution.
I don't know the answer to SuspendThread but I technique I find interesting and usefull to kill a thread is to force it to thow an exception. Have a look at http://www.codeproject.com/threads/threadlibrary.asp[^] which uses this technique. Hope that helps. Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com