Task.Id 属性

定义

获取此 Task 实例的 ID。Gets an ID for this Task instance.

public:
 property int Id { int get(); };
public int Id { get; }
member this.Id : int
Public ReadOnly Property Id As Integer

属性值

Int32

系统分配到此 Task 实例的标识符。The identifier that is assigned by the system to this Task instance.

注解

任务 Id 按需分配,不一定表示任务实例的创建顺序。Task IDs are assigned on-demand and do not necessarily represent the order in which task instances are created. 请注意,尽管冲突非常罕见,但不保证任务标识符是唯一的。Note that although collisions are very rare, task identifiers are not guaranteed to be unique.

若要从任务正在执行的代码内获取当前正在执行的任务的任务 ID,请使用 CurrentId 属性。To get the task ID of the currently executing task from within code that task is executing, use the CurrentId property.

适用于

另请参阅