Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetCurrentThreadId Method

AppDomain.GetCurrentThreadId Method

NOTE: This method is now obsolete. The non-obsolete alternative is ManagedThreadId.

Gets the current thread identifier.

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

[ObsoleteAttribute("AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread.  http://go.microsoft.com/fwlink/?linkid=14202", false)] 
public static int GetCurrentThreadId ()
/** @attribute ObsoleteAttribute("AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread.  http://go.microsoft.com/fwlink/?linkid=14202", false) */ 
public static int GetCurrentThreadId ()
ObsoleteAttribute("AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread.  http://go.microsoft.com/fwlink/?linkid=14202", false) 
public static function GetCurrentThreadId () : int
Not applicable.

Return Value

A 32-bit signed integer that is the identifier of the current thread.

Use the Thread.ManagedThreadId property, which is stable even when the .NET Framework is hosted by an environment that supports fibers (that is, lightweight threads).

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 1.0, 1.1, 2.0
Obsolete (compiler warning) in 3.0

Community Additions

ADD
Show:
© 2015 Microsoft