473,383 Members | 1,874 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,383 software developers and data experts.

CPU Utilization for a thread and killing a thread

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

Mar 6 '06 #1
2 3387
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" <Me******@community.nospam> wrote in message
news:uC*************@TK2MSFTNGP12.phx.gbl...
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

Mar 8 '06 #2
This is the response I got in the MS forums, pretty much the same thing, use
the API.

http://forums.microsoft.com/MSDN/Sho...83208&SiteID=1

Thanks
Wayne

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ux****************@TK2MSFTNGP10.phx.gbl...
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" <Me******@community.nospam> wrote in message
news:uC*************@TK2MSFTNGP12.phx.gbl...
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


Mar 8 '06 #3

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

Similar topics

4
by: Anks | last post by:
hi I am testing my applet to servlet communication program using appletviewer. as soon as i start the applet the cpu utilization reaches to 100%.I am using apache tomcat 4.1 application...
0
by: Joe Kraft | last post by:
I'm hoping someone can help me out. We're running a website that uses XML/XSLT transformations, VB.Net and an Oracle database. Currently the site cannot support more than 6-7 users at a time...
3
by: Dathon | last post by:
I have a Windows service that's built with .NET. The process is meant to run in the background and not suck up too much CPU time. I set the thread priority for the various threads in the service...
1
by: jay | last post by:
Greetings I have a C# windows service that creates several application domains. Each app domain has it's own programs running, doing their own thing, independent of each other. Recently,...
51
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() ...
1
by: Pawan.Ghildiyal | last post by:
Hi everybody As we know that replication process uses 3 threads- 1. Master thread (Binlog Dump) 2. I/O thread 3. Sql Thread Now I have some confusion regarding these thing -- - In peek...
2
by: dm3281 | last post by:
Hello, all. I have 4 web servers in a farm using network load balancing service. All the web applications (there are about 50+ per server) are using ASP.NET 1.1. I have two apppools setup...
0
by: ipramod | last post by:
Hi, I just wanted to calculate CPU Percentage Utilization in ASP.Net application using a thread. I have written following code: protected void Page_Load(object sender, EventArgs e) {...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, Is it possible "kill" the thread of Backgroundworker ? In my Dowork event, I have NOT While for do e.Cancel = true, only have a call to external COM. If I want cancel, calling...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.