Task.IsCanceled 屬性

定義

取得這個 Task 執行個體是否因取消才完成執行。Gets whether this Task instance has completed execution due to being canceled.

public:
 property bool IsCanceled { bool get(); };
public bool IsCanceled { get; }
member this.IsCanceled : bool
Public ReadOnly Property IsCanceled As Boolean

屬性值

如果工作是由於取消而完成,則為 true,否則為 falsetrue if the task has completed due to being canceled; otherwise false.

備註

在下列任一情況下,Task 將會在 Canceled 狀態中完成:A Task will complete in the Canceled state under any of the following conditions:

重要

在工作完成之前,抓取 IsCanceled 屬性的值不會封鎖呼叫執行緒。Retrieving the value of the IsCanceled property does not block the calling thread until the task has completed.

適用於