WorkflowPersistenceService.LoadCompletedContextActivity 方法

定义

在派生类中实现时,将指定的已完成作用域加载回内存。

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

参数

scopeId
Guid

已完成作用域的 Guid

outerActivity
Activity

一个 Activity,表示涵盖已完成作用域的活动。

返回

Activity

表示已完成范围的 Activity

示例

下面的示例演示 LoadCompletedContextActivity 方法的实现。 此示例摘自 FilePersistenceService.cs 文件中的“自定义持久性服务”示例。 有关详细信息,请参阅 自定义持久性服务示例

// 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

注解

工作流运行时引擎使用 LoadCompletedContextActivity 实现补偿。 必须还原已完成作用域的相同副本。 为此,必须从数据存储区中已完成作用域的表示形式中还原有效的 Stream。 然后,必须将此 Stream 传递到重载的 Load 方法之一,用于执行作用域的反序列化。

如果持久性服务无法从其数据存储区加载已完成作用域,则它应引发 PersistenceException 并显示相应的消息。

适用于