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

屬性值

系統指派給這個 Task 執行個體的識別項。The identifier that is assigned by the system to this Task instance.

備註

工作識別碼會隨選指派,不一定代表建立工作實例的順序。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.

若要從工作執行的程式碼中取得目前正在執行之工作的工作識別碼,請使用 CurrentId 屬性。To get the task ID of the currently executing task from within code that task is executing, use the CurrentId property.

適用於

另請參閱