Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a list of all threads in a .Net application?

I'm trying to troubleshoot a larger multiprocessing issue -- I suspect a client library is creating a foreground thread, and I'm trying to see if that theory is correct.

In order to do that, I'd like to be able to log a list of all threads in a process, what their state is, and whether they are background or foreground.

I've seen Process.GetCurrentProcess().Threads, but that returns a ProcessThread object, not a System.Thread. ProcessThread doesn't have all of the properties that a System.Thread does.

Is there a way to get the list of System.Threads?

like image 524
Jeremy Dunck Avatar asked Sep 01 '25 16:09

Jeremy Dunck


2 Answers

How about using Sysinternal's ProcMon

As @jvilalta pointed out, Process Explorer is also a good option.

like image 144
Amirshk Avatar answered Sep 04 '25 05:09

Amirshk


Visual Studio natively has the ability to view all active threads, OR you could use DebugInspector (not sure of the url, sorry).

From C#, not sure how this can be done.

like image 43
GurdeepS Avatar answered Sep 04 '25 07:09

GurdeepS