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

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com 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
)

Parameters

completionState
Type: System.Activities.ActivityInstanceState

The state of the workflow instance.

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

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

terminationException
Type: System.Exception

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

timeout
Type: System.TimeSpan

The time interval during which the asynchronous operation must complete.

callback
Type: System.AsyncCallback

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

state
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");
    }
    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);
}

.NET Framework
Available since 4.0
Return to top
Show: