TrackingWorkflowTerminatedEventArgs.Exception 屬性

定義

取得導致工作流程執行個體終止的例外狀況。

public:
 property Exception ^ Exception { Exception ^ get(); };
public Exception Exception { get; }
member this.Exception : Exception
Public ReadOnly Property Exception As Exception

屬性值

導致工作流程執行個體終止的 Exception

範例

下列程式碼範例將示範一個名稱為 WriteTerminatedEventArgs 的方法,該方法會擷取 TrackingWorkflowTerminatedEventArgs。 程式碼會檢查 Exception 屬性是否為 null (Visual Basic 中的 Nothing)。 如果不是,程式碼會將與 Exception 屬性關聯的訊息寫入主控台。 如果 Exceptionnull (Nothing),程式碼不會將任何例外狀況資訊寫入主控台中。

這個程式碼範例是 Program.cs 檔案中<EventArgs 追蹤 SDK>範例的一部分。 如需詳細資訊,請參閱 EventArgs 追蹤範例

static void WriteTerminatedEventArgs(string eventDescription, TrackingWorkflowTerminatedEventArgs terminatedEventArgs, DateTime eventDataTime)
{
    Console.WriteLine("\nTerminated Event Arguments Read From Tracking Database:\n");
    Console.WriteLine("EventDataTime: " + eventDataTime.ToString());
    Console.WriteLine("EventDescription: " + eventDescription);
    if (null != terminatedEventArgs.Exception)
    {
        Console.WriteLine("TerminatedEventArgs Exception Message: " + terminatedEventArgs.Exception.Message.ToString());
    }
}
Shared Sub WriteTerminatedEventArgs(ByVal eventDescription As String, ByVal terminatedEventArgs As TrackingWorkflowTerminatedEventArgs, ByVal eventDataTime As DateTime)
    Console.WriteLine(vbCrLf + "Terminated Event Arguments Read From Tracking Database:")
    Console.WriteLine("EventDataTime: " + eventDataTime.ToString(CultureInfo.CurrentCulture))
    Console.WriteLine("EventDescription: " + eventDescription)
    If terminatedEventArgs.Exception IsNot Nothing Then
        Console.WriteLine("TerminatedEventArgs Exception Message: " + terminatedEventArgs.Exception.Message.ToString())
    End If
End Sub

備註

工作流程執行個體因為未處理的例外狀況而終止時,Exception 會包含未處理的例外狀況。

當工作流程實例由主機呼叫 WorkflowInstance.TerminateTerminateActivity 活動終止時, Exception 包含 WorkflowTerminatedExceptionMessage 屬性設定為終止原因描述的 。 如果主機終止工作流程執行個體,它會在 string 參數中提供此描述給 WorkflowInstance.Terminate。如果是 TerminateActivity 終止工作流程執行個體,則由 TerminateActivity.Error 提供描述。

適用於

另請參閱