How do I make a thread dump in .NET ? (a la JVM thread dumps)

前端 未结 6 1781
暖寄归人
暖寄归人 2021-01-30 17:52

I have found no way of dumping the stack on all threads in .NET. Neither a signal to be send to the process nor programatic access to all the threads. I can only get access to t

6条回答
  •  忘了有多久
    2021-01-30 18:28

    There is a variety of handy classes in the System.Diagnostics that can help you with debugging and gathering various tracking information, i.e. StackTrace.

    There is a wonky Process class that can be used to get the number of executing threads but very few details. Use the following Snippet:

    Using  System.Diagnostics;
    
    var threads = Process.GetCurrentProcess().Threads;
    

    Okay after looking a little bit more it appears the easiest way to capture all the current stacks is through a mini dump and a tool like SOS or if you are running vista this.

    Good luck.

提交回复
热议问题