WorkflowPersistenceService.LoadCompletedContextActivity Method

Definition

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

C#
protected internal abstract System.Workflow.ComponentModel.Activity LoadCompletedContextActivity(Guid scopeId, System.Workflow.ComponentModel.Activity outerActivity);

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.

C#
// 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;
}

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

제품 버전
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1