create new StackTrace-object for a thread


Markus Eßmayr


in my application I need to get the current executing location of a thread.
Until now I did this by

Thread executingThread;
StackTrace executionLocation = new StackTrace(executingThread, false);

This works very good.
Since .NET Framework 2.0 the Suspend and Resume functions are marked
But the documentation of the StackTrace constructor still says "If a
StackTrace is created with a target thread that is not the current thread,
the target thread must first be suspended."

Can anyone please tell me how to suspend a thread without using

Thanks in advance!


Lloyd Dupont

It's obsolete because....
the little caution box in the documenttation, down the page.
Let me copy it there for you:
Do not use the Suspend and Resume methods to synchronize the activities of
threads. You have no way of knowing what code a thread is executing when you
suspend it. If you suspend a thread while it holds locks during a security
permission evaluation, other threads in the AppDomain might be blocked. If
you suspend a thread while it is executing a class constructor, other
threads in the AppDomain that attempt to use that class are blocked.
Deadlocks can occur very easily.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question