How can I get the status of the program?

I am watching a program and want to kill it if it is in the "wait: executive" state for some time.

Here is a screenshot of Process Explorer:

State: wait: executive

How can I get this status by code? Or maybe they will tell me what exactly this means? This will help me find the right query to solve my problem.

+6
source share
2 answers

This is not a program state, but a stream state. One process can have many threads.

You can call WaitForSingleObject to determine some states.

You can also create a WMI instance using COM and select the Win32_Thread class .

Here is an example.

Additional information here: How to determine if a win32 thread is in standby or connection or sleep mode in C ++

+2
source

This means that the thread is waiting for the scheduler / component executive

It can be selected using WMI Win32_Thread (or .net System.Diagnostics.ProcessThread WaitReason )

+2
source

Source: https://habr.com/ru/post/926093/


All Articles