Editar

Compartilhar via


WorkflowPersistenceService.LoadCompletedContextActivity Method

Definition

When implemented in a derived class, loads the specified completed scope back into memory.

protected public:
 abstract System::Workflow::ComponentModel::Activity ^ LoadCompletedContextActivity(Guid scopeId, System::Workflow::ComponentModel::Activity ^ outerActivity);
protected internal abstract System.Workflow.ComponentModel.Activity LoadCompletedContextActivity (Guid scopeId, System.Workflow.ComponentModel.Activity outerActivity);
abstract member LoadCompletedContextActivity : Guid * System.Workflow.ComponentModel.Activity -> System.Workflow.ComponentModel.Activity
Protected Friend MustOverride Function LoadCompletedContextActivity (scopeId As Guid, outerActivity As Activity) As Activity

Parameters

scopeId
Guid

The Guid of the completed scope.

outerActivity
Activity

An Activity that represents the activity that encloses the completed scope.

Returns

An Activity that represents the completed scope.

Examples

The following example demonstrates an implementation of the LoadCompletedContextActivity method. This example is from the Custom Persistence Service sample, from the FilePersistenceService.cs file. For more information, see Custom Persistence Service Sample.

// Load the completed activity state.
protected override Activity LoadCompletedContextActivity(Guid activityId, Activity outerActivity)
{
    Console.WriteLine("Loading completed activity context: {0}", activityId);
    byte[] workflowBytes = DeserializeFromFile(activityId);
    Activity deserializedActivities = WorkflowPersistenceService.RestoreFromDefaultSerializedForm(workflowBytes, outerActivity);
    return deserializedActivities;
}
' Load completed activity state.
Protected Overrides Function LoadCompletedContextActivity(ByVal scopeId As System.Guid, ByVal outerActivity As System.Workflow.ComponentModel.Activity) As System.Workflow.ComponentModel.Activity
    Console.WriteLine("Loading completed activity context: 0}", scopeId)
    Dim workflowBytes As Byte() = DeserializeFromFile(scopeId)
    Dim deserializedActivities As Activity = WorkflowPersistenceService.RestoreFromDefaultSerializedForm(workflowBytes, outerActivity)
    Return deserializedActivities
End Function

Remarks

The workflow runtime engine uses LoadCompletedContextActivity to implement compensation. You must restore an identical copy of the completed scope. To do this, you must restore a valid Stream from your representation of the completed scope in the data store. Then you must pass this Stream to one of the overloaded methods of Load to perform deserialization of the scope.

If your persistence service cannot load the completed scope from its data store, it should throw a PersistenceException with an appropriate message.

Applies to