WorkflowCreationContext.OnBeginWorkflowCompleted Method (ActivityInstanceState, IDictionary<String, Object>, Exception, TimeSpan, AsyncCallback, Object)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Begins an asynchronous operation to perform workflow instance completion notification. This method is called when the workflow instance associated with this WorkflowCreationContext completes. Derived classes can override this operation to perform custom actions on workflow instance completion.

Namespace:   System.ServiceModel.Activities
Assembly:  System.ServiceModel.Activities (in System.ServiceModel.Activities.dll)

protected internal virtual IAsyncResult OnBeginWorkflowCompleted(
	ActivityInstanceState completionState,
	IDictionary<string, object> workflowOutputs,
	Exception terminationException,
	TimeSpan timeout,
	AsyncCallback callback,
	object state


Type: System.Activities.ActivityInstanceState

The state of the workflow instance.

Type: System.Collections.Generic.IDictionary<String, Object>

A collection of key/value pairs that contain output generated by the workflow instance.

Type: System.Exception

If present, an error that caused the workflow to terminate.

Type: System.TimeSpan

The time interval during which the asynchronous operation must complete.

Type: System.AsyncCallback

The location in an application to which control returns when the asynchronous operation completes.

Type: System.Object

User-defined state.

Return Value

Type: System.IAsyncResult

The status of the asynchronous operation.

The following example shows how to implement the OnBeginWorkflowCompleted method.

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");
        Console.WriteLine("InstanceId :" + InstanceId + " OnBeginWorkflowCompleted");
        WorkflowHostingResponseContext responseContext = UserState as WorkflowHostingResponseContext;
        if (responseContext != null)
            foreach (object value in workflowOutputs.Values)
                responseContext.SendResponse(value, null);
    return base.OnBeginWorkflowCompleted(completionState, workflowOutputs, faultedReason, timeout, callback, state);

.NET Framework
Available since 4.0
Return to top