Details of all running threads

P

PromisedOyster

We are having issues with our application periodically hanging. I have
a timer event already running and I would like to know the state of
all the running threads (foreground and background) so that I can
output it to the event log.

I can use the ThreadPool to get me the no of available threads and use
Thread.CurrentThread to get details of the current thread, but how can
I determine the status of all running threads?

I was looking for something like Thread.GetRunningThreads to return a
collection of threads.

Any ideas??
 
M

Marc Gravell

It sounds like a classic deadlock - typical causes are either locking
multiple objects in different orders, or thread A doing an Invoke to
the UI thread, where the UI wants a lock that thread A hasn't
released.

if it happens in debug, then use the thread/call-stack windows to
identify.

You can hold of a lite version of the threads with
Process.GetCurrentProcess().Threads, but I doubt it will have enough
information for you.

If it only happens in production, SOS may be an option - i.e. attach
the low-level debugger to the running exe and find out

Marc
 

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