473,327 Members | 2,094 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,327 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 5614
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.