Tracking down threads created within a ASP.NET app

G

Guest

I am using the System.Diagnostics.Process class in order to loop thru all the
processes running. Within that loop I am looking for the process name
“aspnet_wp†in order to get the process ID. Once I find it, I use the process
ID to find all the threads running under that process. This works fine so
far. What I would like to do is to be able to detect/find the threads that my
ASP.NET app. created.

I have tried giving the threads I created a name (t1.Name = "SampleThread"),
but I don’t find a way to search for these names.

My question is: How can I find the threads I create from within my ASP.NET
app?

Thanks in advance.
 
S

Scott Allen

Hi mareal:

Can you keep a reference around when you create the thread?

The problem with Process.Threads is that it returns a collection of
operating system threads. A thread in .NET is a logical thread and
doesn't have to have a 1:1 mapping with operating system threads
(although in 1.x they do, MS didn't want to tie themselves to this
implementation).
 
G

Guest

Thanks Scott. If keeping a reference is the only way to check their status, I
will do that. Something else, I am noticing that the threads I create die
after 20 minutes or so of inactivity. I have added Try-Catch block in the
thread itself hoping that when the thread dies, an exception will be thrown.
But I am not seeing any of that. How can I recover from a dying thread?
 

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