c++thread-state

getting a thread state in c++/windows



There must be a function that gets the current status of a thread in the system because
there is this application: http://www.softwareverify.com/cpp/thread-status-monitor/index.html

It must be using some sort of API function or something... How can I get a thread state myself in C++/Windows?
thanks :)

(this is my last question for today. I promise :))


Solution

  • You can use the following examples to get the running processes and, when you have a process ID, the threads.

    Taking a Snapshot and Viewing Processes

    Traversing the Thread List

    EDIT: After getting the handle to the thread(s) you are interested in you can call GetExitCodeThread but that will only tell you if the thread is STILL_ACTIVE until it ends, when you can find the exit code.

    While searching for the additional information for your comment I also came across this thread on SO which might be of interest to you.