CPU Utilization for a thread and killing a thread

W

Wayne Sepega

I have the following code:

Process[] processes = Process.GetProcessesByName("IEXPLORE");
foreach (Process process in processes)
{
foreach (ProcessThread t in process.Threads)
{
int threadId = t.Id;
}
}


From here now that I have access to the threads in a process how can I do
the following:

Tell the CPU % the thread currently has?
Kill the thread?

We have a process that runs away once in a while and using one of
sysinternals tools have determined that we can SAFELY kill the thread and
the app will just restart it. We want to automate this using C#.

Thanks
Wayne
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

AFAIK there is no way of doing this (at least in the framework) you could
take a look at the win32 API directly
 
W

Wayne Sepega

This is the response I got in the MS forums, pretty much the same thing, use
the API.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=283208&SiteID=1

Thanks
Wayne

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

AFAIK there is no way of doing this (at least in the framework) you could
take a look at the win32 API directly


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



Wayne Sepega said:
I have the following code:

Process[] processes = Process.GetProcessesByName("IEXPLORE");
foreach (Process process in processes)
{
foreach (ProcessThread t in process.Threads)
{
int threadId = t.Id;
}
}


From here now that I have access to the threads in a process how can I do
the following:

Tell the CPU % the thread currently has?
Kill the thread?

We have a process that runs away once in a while and using one of
sysinternals tools have determined that we can SAFELY kill the thread and
the app will just restart it. We want to automate this using C#.

Thanks
Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top