473,396 Members | 2,009 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.

Grokking Active Threads

I'm currently working on a page for our ASP.Net application that
displays some information about the runtime for the current machine.
The ultimate goal is to be able to determine what threads are running,
why they are running (i.e. where and when they got started), what
state they are in, and if there are any orphaned or dead threads that
should have been closed but weren't.

My problem, is that I have no idea how to get the "name" of a thread.
I can use Thread.CurrentThread.Name to get the name of the current
thread, but I can't get the name of any other threads using the
System.Diagnostics.Process.GetCurrentProcess().Thr eads
(ProcessThreadCollection) collection.

Is there a way for me to get the "name" of a thread using only it's
Thread ID? Also, is there a way to determine which thread created
which thread (that would be great, but I could fake it using the
Thread.Name property).

Bryan
Nov 13 '05 #1
1 5620
Bryan,

The Name property is something that is exclusive to CLR threads (or
rather, the .NET representation of threads). Threads that are doled out by
the OS do not have names associated with them. In order to get the name of
a Thread object, you would have to attach to the running instance of the CLR
for that process, and then find the Thread objects and query the Name
property.

I don't even think something like this is even possible, and if it is,
it is bound to be very, very ugly.

If it was up to me, I would drop it, because you can't guarantee that a
name will always be there. Not all threads run in the context of the
runtime, so when you come across a thread that doesn't (and there will be
plenty if you are doing this machine-wide), you will not have that
information anyways.

Also, the threads don't really expose which thread created it, so you
can't get at that information either.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Bryan Murphy" <ne**@humaninterests.com> wrote in message
news:b1**************************@posting.google.c om...
I'm currently working on a page for our ASP.Net application that
displays some information about the runtime for the current machine.
The ultimate goal is to be able to determine what threads are running,
why they are running (i.e. where and when they got started), what
state they are in, and if there are any orphaned or dead threads that
should have been closed but weren't.

My problem, is that I have no idea how to get the "name" of a thread.
I can use Thread.CurrentThread.Name to get the name of the current
thread, but I can't get the name of any other threads using the
System.Diagnostics.Process.GetCurrentProcess().Thr eads
(ProcessThreadCollection) collection.

Is there a way for me to get the "name" of a thread using only it's
Thread ID? Also, is there a way to determine which thread created
which thread (that would be great, but I could fake it using the
Thread.Name property).

Bryan

Nov 13 '05 #2

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

Similar topics

3
by: Maxwell Hammer | last post by:
An application I am developing executes many threads and then has a "monitor" part that waits for certain events. One of these events causes the application to have to shutdown. On shutdown the...
1
by: Max | last post by:
I thought restricted mode had been removed from Python but it seems to be active for Python 2.3.5 +. I'm using the JEP product which allows integration of Java with Python (see...
3
by: Shane Suebsahakarn | last post by:
I have a rather odd problem that I'm at a loss to explain. The mdb is in A2K2 format, and has many tables linked to around 3-4 different back end mdbs. It is running on a Win2K3 server (set up as...
2
by: Naveen Mukkelli | last post by:
Hi, I'm working on a multi-threaded application. I'm using ThreadPools. One of the requirements of the application is, if certain exception occurs all the counters have to be reset. I have...
1
by: bsmith | last post by:
I would like to determine if an Active Directory user account is locked. Active directory is running on W2k3 server. I also want to do this using the DirectoryEntry object. I have read a lot of...
3
by: Pedro | last post by:
Hi all, I would like to know, how can I check the name of the current user that is Log on in O.S XP. Hi already try the Environment.UserName.ToString(); but is not what i would like to...
1
by: sweety_s | last post by:
I need to get the list of active threads in a process. I have used NtQuerySystemInformation API with SystemProcessInformation but i get all the no: of threads in the process, but i dont get the...
1
by: Dom | last post by:
Is there a way to find all the threads that are currently active? Is there something like a "Threads" class, similar to the "Controls" class, so that I can do something like: foreach (Thread t...
23
by: =?GB2312?B?0rvK18qr?= | last post by:
Hi all, Recently I had a new coworker. There is some dispute between us. The last company he worked for has a special networking programming model. They split the business logic into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.