共用方式為


WorkflowCreationContext.OnBeginWorkflowCompleted 方法

定義

開始非同步作業,以執行工作流程執行個體完成通知。 與這個 WorkflowCreationContext 相關聯的工作流程執行個體完成時,會呼叫這個方法。 衍生類別可以覆寫這個作業,以便在工作流程執行個體完成時執行自訂動作。

protected public:
 virtual IAsyncResult ^ OnBeginWorkflowCompleted(System::Activities::ActivityInstanceState completionState, System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ workflowOutputs, Exception ^ terminationException, TimeSpan timeout, AsyncCallback ^ callback, System::Object ^ state);
protected internal virtual IAsyncResult OnBeginWorkflowCompleted (System.Activities.ActivityInstanceState completionState, System.Collections.Generic.IDictionary<string,object> workflowOutputs, Exception terminationException, TimeSpan timeout, AsyncCallback callback, object state);
abstract member OnBeginWorkflowCompleted : System.Activities.ActivityInstanceState * System.Collections.Generic.IDictionary<string, obj> * Exception * TimeSpan * AsyncCallback * obj -> IAsyncResult
override this.OnBeginWorkflowCompleted : System.Activities.ActivityInstanceState * System.Collections.Generic.IDictionary<string, obj> * Exception * TimeSpan * AsyncCallback * obj -> IAsyncResult
Protected Friend Overridable Function OnBeginWorkflowCompleted (completionState As ActivityInstanceState, workflowOutputs As IDictionary(Of String, Object), terminationException As Exception, timeout As TimeSpan, callback As AsyncCallback, state As Object) As IAsyncResult

參數

completionState
ActivityInstanceState

工作流程執行個體的狀態。

workflowOutputs
IDictionary<String,Object>

索引鍵/值組的集合,其中包含工作流程執行個體所產生的輸入。

terminationException
Exception

如果存在,表示造成工作流程終止的錯誤。

timeout
TimeSpan

非同步作業必須在期間內完成的時間間隔。

callback
AsyncCallback

應用程式中的位置,當非同步作業完成時,會傳回控制項至這個位置。

state
Object

使用者定義的狀態。

傳回

非同步作業的狀態。

範例

下列範例將示範如何實作 OnBeginWorkflowCompleted 方法。

protected override IAsyncResult OnBeginWorkflowCompleted(ActivityInstanceState completionState, IDictionary<string, object> workflowOutputs,
    Exception faultedReason, TimeSpan timeout, AsyncCallback callback, object state)
{
    if (completionState == ActivityInstanceState.Faulted)
    {
        Console.WriteLine("InstanceId :" + InstanceId + " OnBeginWorkflowTerminated");
    }
    else if (completionState == ActivityInstanceState.Canceled)
    {
        Console.WriteLine("InstanceId :" + InstanceId + " OnBeginWorkflowCanceled");
    }
    else
    {
        Console.WriteLine("InstanceId :" + InstanceId + " OnBeginWorkflowCompleted");
        WorkflowHostingResponseContext responseContext = UserState as WorkflowHostingResponseContext;
        if (responseContext != null)
        {
            foreach (object value in workflowOutputs.Values)
            {
                responseContext.SendResponse(value, null);
                break;
            }
        }
    }
    return base.OnBeginWorkflowCompleted(completionState, workflowOutputs, faultedReason, timeout, callback, state);
}

適用於