Task.IsFaulted 屬性

定義

取得 Task 是否因未處理的例外狀況才完成。Gets whether the Task completed due to an unhandled exception.

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

屬性值

如果工作擲回未處理的例外狀況,則為 true,否則為 falsetrue if the task has thrown an unhandled exception; otherwise false.

備註

如果 trueIsFaulted,則工作的 Status 等於 Faulted,而且其 Exception 屬性將為非 null。If IsFaulted is true, the task's Status is equal to Faulted, and its Exception property will be non-null.

重要

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

適用於