Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting idle process

Status
Not open for further replies.

bbolte

Programmer
Sep 30, 2002
113
0
0
US
is there anyway to detect whether a process is idle/ready/busy? i've been searching through the API's and WMI docs and still haven't found it. i can get what's running and shut down what i want, but i would like to know if it's busy before i shut it down. anyway to do this?
 
I don't know if you can do this, but even if you could you couldn't be sure if it is very busy when you actually shut it down.

/JOlesen
 
» idle/ready/busy

Windows has no concept of this. I guess you could define "idle" to mean "has no messages in the thread queue", but you can't read another thread's message queue.

You could try using hooks, and tracking when the last time a thread has processed a message. That would provide a fairly good implementation of "idle/busy" for User-Interface threads.

Because worker threads do not usually process messages, you should have the process signal a named event or something when it's busy, so that you can test with WaitForSingleObject with a timeout of zero.

I REALLY hope this helps.
Will
 
makes sense. thanks for the replies...
 
You might like to check out WaitForInputIdle or MsgWaitForMultipleObjects with a wake mask of QS_INPUT. Additionally AttachThreadInput will give you access to another thread's message queue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top