我可以在我的c#应用程序中获取所有线程的堆栈跟踪吗? [英] Can I get the stack traces of all threads in my c# app?
问题描述
C#可以轻松获取抛出异常的线程的堆栈跟踪,但是我会喜欢在抛出异常的时候另外获取当前在我的AppDomain中执行的每个其他线程的堆栈跟踪。
这是可能吗?
CodePlex上有一个名为托管堆栈资源管理器(我相信来自微软)。它使用调试和分析API捕获正在运行的.Net应用程序中的线程的堆栈跟踪,而无需修改应用程序。
您可以运行应用程序直到您遇到问题,然后使用此工具分析它,以捕获所有正在运行的线程的当前堆栈跟踪。这种方法的好处是您不需要修改应用程序(测试它可能会改变其行为),并且该工具是免费的。
I'm debugging an apparent concurrency issue in a largish app that I hack on at work. The bug in question only manifests on certain lower-performance machines after running for many (12+) hours, and I have never reproduced it in the debugger. Because of this, my debugging tools are basically limited to analyzing log files.
C# makes it easy to get the stack trace of the thread throwing the exception, but I'd like to additionally get the stack traces of every other thread currently executing in my AppDomain at the time the exception was thrown.
Is this possible?
There is a tool on CodePlex called Managed Stack Explorer (that I believe originated from Microsoft). It uses the debugging and profiling API to capture the stack traces of the threads in a running .Net application, without the need to modify the application.
You could run your application until you experience the issue, then analyse it using this tool to capture the current stack traces of all running threads. The benefit of this approach is that you leave your application unmodified (instrumenting it may change its behaviour), and the tool is free.
这篇关于我可以在我的c#应用程序中获取所有线程的堆栈跟踪吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!