共用方式為


WorkflowApplicationCompletedEventArgs.TerminationException 屬性

定義

取得與工作流程執行個體終止相關聯的例外狀況。

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

屬性值

與工作流程執行個體終止相關聯的例外狀況。

範例

下列程式碼範例會檢查傳遞給 WorkflowApplicationCompletedEventArgs 執行個體之 Completed 處理常式的 WorkflowApplication,並且顯示工作流程如何完成的相關資訊。

wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
    if (e.CompletionState == ActivityInstanceState.Faulted)
    {
        Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
        Console.WriteLine("Exception: {0}\n{1}",
            e.TerminationException.GetType().FullName,
            e.TerminationException.Message);
    }
    else if (e.CompletionState == ActivityInstanceState.Canceled)
    {
        Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
    }
    else
    {
        Console.WriteLine("Workflow {0} Completed.", e.InstanceId);

        // Retrieve the outputs of the workflow.
        foreach (var kvp in e.Outputs)
        {
            Console.WriteLine("Name: {0} - Value {1}",
                kvp.Key, kvp.Value);
        }

        // Outputs can be directly accessed by argument name.
        Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
    }
};

適用於