WorkflowPersistenceService.LoadCompletedContextActivity 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在衍生類別中實作時,將指定的完成範圍載回記憶體中。
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
參數
傳回
表示已完成範圍的 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。