WorkflowApplicationCompletedEventArgs.CompletionState 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得工作流程執行個體的完成狀態,這個完成狀態會表示工作流程執行個體是否已成功完成、已取消或是發生錯誤的狀態。
public:
property System::Activities::ActivityInstanceState CompletionState { System::Activities::ActivityInstanceState get(); };
public System.Activities.ActivityInstanceState CompletionState { get; }
member this.CompletionState : System.Activities.ActivityInstanceState
Public ReadOnly Property CompletionState As ActivityInstanceState
屬性值
工作流程執行個體的完成狀態,這個完成狀態會表示工作流程執行個體是否已成功完成、已取消或是發生錯誤的狀態。
範例
下列程式碼範例會檢查傳遞給 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"]);
}
};