Print thread stack of all threads of a process

这一生的挚爱 提交于 2019-12-24 09:25:06

问题


I have a .NET application with a button. When I click the button I want the application to print thread stack of all threads to debug console.

Is it possible to do it?

Datte.


回答1:


You can use the StackTrace class (System.Diagnostics) to get a stack trace of a Thread. You'd need to enumerate the threads, and (unfortunately) suspend them first, though.

Here's the constructor of interest: http://msdn.microsoft.com/en-us/library/t2k35tat.aspx

You may well need to create your own ThreadPool implementation, or extend someone else's. As far as I can see/tell there's no way to enumerate them.




回答2:


This might be useful to someone finding this question http://stackdump.codeplex.com/



来源:https://stackoverflow.com/questions/6544968/print-thread-stack-of-all-threads-of-a-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!