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

Task.CurrentId Property

Returns the ID of the currently executing Task.

Namespace:  System.Threading.Tasks
Assemblies:   System.Threading.Tasks (in System.Threading.Tasks.dll)
  mscorlib (in mscorlib.dll)

'Declaration
Public Shared ReadOnly Property CurrentId As Nullable(Of Integer)

Property Value

Type: System.Nullable(Of Int32)
An integer that was assigned by the system to the currently-executing task.

CurrentId is a static (Shared in Visual Basic) property that is used to get the identifier of the currently executing task from the code that the task is executing. It differs from the Id property, which returns the identifier of a particular Task instance. If you attempt to retrieve the CurrentId value from outside the code that a task is executing, the property returns Nothing.

Note that although collisions are very rare, task identifiers are not guaranteed to be unique.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft