Link to home
Start Free TrialLog in
Avatar of abnc
abnc

asked on

Detect When Application Is Idle

I am looking for the best way to detect when a specific application is idle. In Task Manager there is the CPU column that indicates if a process is 0 or some other value. I want to know when a specific process is at 0 and remains in that state. I have a particular app that is always running in the background and should be consuming some CPU time all the time. For the most part it does, but occasionally it goes idle and I need to know when it does.
Avatar of CarlVerret
CarlVerret
Flag of Canada image

Hi,

Have you ever tried to add and Handler on the Application.Idle event ?
ASKER CERTIFIED SOLUTION
Avatar of JasonRawlins
JasonRawlins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of abnc
abnc

ASKER

My console app is endeavoring to check the idle state of another app. That app is not one I have written so I cannot change the underlying code. I need to know when that app's process is idle using no CPU time.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of abnc

ASKER

I have looked at the system diagnostics but don't see yet anyway to see what the current status of a specific process is regarding CPU time. I see I can get the TotalProcessorTime, but I want to know if that process is using any CPU time at a given moment. Obviously, Windows Task Manager is getting that data and showing it on the Processes Tab.

By way of information, the app I am checking shows up in the list of Applications in Windows Task Manager, but on random occasions it disappears from that list but is still listed among the processes. However, it is showing 00 CPU time and I need to know when it is in that state. Perhaps there is some way of checking for it among the list of applications rather than processes, although I would prefer to be able to check it's process current status.
Hello, abnc

An application is always associated with a process. In this case, I think you want to monitor the process and take action based on its state.

In order to continually monitor the processes on your machine (similar to the task manager) you may need to create a Windows service. A Windows service is often used for long-running processes (such as continually monitoring processes) that don't interfere with other applications and users.

Look at http://msdn2.microsoft.com/en-us/library/d56de412(VS.80).aspx to see how you can create and set up a Windows service application.
Avatar of abnc

ASKER

Several of these things I already had tried and is not the exact solution I was seeking. I finally came up with a method using part of what I had already tried and some of what was suggested.