StackTrace Constructor (Thread, Boolean)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Note: This API is now obsolete.

Initializes a new instance of the StackTrace class for a specific thread, optionally capturing source information.

Do not use this constructor overload.

Namespace:   System.Diagnostics
Assembly:  mscorlib (in mscorlib.dll)

[ObsoleteAttribute("This constructor has been deprecated.  Please use a constructor that does not require a Thread parameter.")]
public StackTrace(
	Thread targetThread,
	bool needFileInfo


Type: System.Threading.Thread

The thread whose stack trace is requested.

Type: System.Boolean

true to capture the file name, line number, and column number; otherwise, false.

Exception Condition

The thread targetThread is not suspended.


Do not use this constructor. It is obsolete, and there is no recommended alternative. When you suspend a thread, you have no way of knowing what code it is executing, and deadlocks can occur very easily. For example, 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.

.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top