Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

StackTrace Constructor (Thread, Boolean)

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.  http://go.microsoft.com/fwlink/?linkid=14202")]
public StackTrace(
	Thread targetThread,
	bool needFileInfo
)

Parameters

targetThread
Type: System.Threading.Thread

The thread whose stack trace is requested.

needFileInfo
Type: System.Boolean

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

ExceptionCondition
ThreadStateException

The thread targetThread is not suspended.

Important noteImportant

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

Supported in: 4, 3.5, 3.0, 2.0, 1.1
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5.2

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Obsolete (compiler warning) in Windows Phone 8.1

Obsolete (compiler warning) in Windows Phone Silverlight 8.1

Obsolete (compiler warning) in Windows Phone Silverlight 8
Show:
© 2015 Microsoft