StackTrace Constructor (Thread, Boolean)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com 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.  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.

Exception Condition
ThreadStateException

The thread targetThread is not suspended.

System_CAPS_importantImportant

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
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: