In java it is possible to get a snapshot of the stacktraces of all running threads. This is done with java.lang.Thread.getAllStackTraces() (it returns Map<Thread,StackTraceElement[]>).
How can the same thing be done with .net?
In java it is possible to get a snapshot of the stacktraces of all running threads. This is done with java.lang.Thread.getAllStackTraces() (it returns Map<Thread,StackTraceElement[]>).
How can the same thing be done with .net?
There is a StackTrace class
var trace = new System.Diagnostics.StackTrace(exception);
http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx
You can loop on System.Diagnostics.Process.GetCurrentProcess().Threads and for each Thread create a StackTrace object with the .ctor that takes a Thread as its param.
Try this one
var proc = System.Diagnostics.Process.GetCurrentProcess();
var threads = proc.Threads;
var res = new Dictionary<Thread, StackTrace>();
foreach (Thread thread in threads)
{
var stackTrace = new StackTrace(thread, true);
res.Add(thread, stackTrace);
}
In res u get the dictionary with the mapping u want :)