473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can can one determine % CPU in use by a spawned process

I have a task to create an app to rebuild indexes for an ancient
program. The program has an API, but leveraging it requires the app's
UI to launch. OK, that's fine, I can just ignore it... at least it
unloads when I tell it to. The problem is that occasionally there is
one thing or another wrong with one of the files needing reindexed and
the app pops up a dialog box for the user to respond to. I've never
heard of this kind of silliness with an API. If one of these dialogs
pops up, it's acceptable for me to email an operator about the
particular file and let them manually resolve the issue.

What I need to do is be able to look at % CPU for the process so I can
guess whether the app is waiting for someone to click "OK" or if it's
still working. There are approximately 79,000 files to be reindexed
and some take as long as 15 minutes to complete, so we really need to
be able to respond to a "hung" reindex and kill it so we can move on
to the next.

Thanks!

--
Jason Kendall
ja**********@hotmail.com
Dec 7 '05 #1
2 1064
use WMI ( System.Management )
you can use SQL like WHERE clause to search by processID

Compare obtained usermodetime with SystemIdlePrcess time and you will get
what you need.
SystemIdleProcess id is 0.

using System;
using System.Management;

class Sample
{
public static void Main()
{
ManagementClass c = new ManagementClass("Win32_Process");

foreach (ManagementObject o in c.GetInstances())
{
Console.WriteLine("Process Load= {0}", o["UserModeTime"]);
}
}
}
--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Jason Kendall" <ja**********@hotmail.com> wrote in message
news:g4********************************@4ax.com...
I have a task to create an app to rebuild indexes for an ancient
program. The program has an API, but leveraging it requires the app's
UI to launch. OK, that's fine, I can just ignore it... at least it
unloads when I tell it to. The problem is that occasionally there is
one thing or another wrong with one of the files needing reindexed and
the app pops up a dialog box for the user to respond to. I've never
heard of this kind of silliness with an API. If one of these dialogs
pops up, it's acceptable for me to email an operator about the
particular file and let them manually resolve the issue.

What I need to do is be able to look at % CPU for the process so I can
guess whether the app is waiting for someone to click "OK" or if it's
still working. There are approximately 79,000 files to be reindexed
and some take as long as 15 minutes to complete, so we really need to
be able to respond to a "hung" reindex and kill it so we can move on
to the next.

Thanks!

--
Jason Kendall
ja**********@hotmail.com

Dec 7 '05 #2
<smacks head>

I didn't think to consider WMI.

Thanks!

--
Jason Kendall
ja**********@hotmail.com
On Wed, 7 Dec 2005 15:33:55 +0200, "Vadym Stetsyak" <va*****@ukr.net>
wrote:
use WMI ( System.Management )
you can use SQL like WHERE clause to search by processID

Compare obtained usermodetime with SystemIdlePrcess time and you will get
what you need.
SystemIdleProcess id is 0.

using System;
using System.Management;

class Sample
{
public static void Main()
{
ManagementClass c = new ManagementClass("Win32_Process");

foreach (ManagementObject o in c.GetInstances())
{
Console.WriteLine("Process Load= {0}", o["UserModeTime"]);
}
}
}

Dec 7 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Mike M | last post by:
Is it possible? In the parent process, I have a socket that binds, listens and then accepts new connections (which creates new sockets in the process). I want to be able to pass some of these new...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a C# application in which I start another process which produces output to stdout and stderr. In fact, that process is the uSoft VS2005 C/C++ compiler itself! I would like to...
0
by: loorthu | last post by:
I am noticing that pexpect kills any child that it is spawned when the parent is terminated using SIGINT (e.g Ctrl-C on the shell), but not when it is killed by SIGKILL (e.g 'kill -9' on the parent...
2
by: subrahmanya | last post by:
Hi All Does any one has idea about how to set stdout and stderr to a spawned process? I don't want to have all the handles of the parent process in the child process but I want only one of it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.