Share via


WorkflowInstance.Load 方法

定义

加载先前卸载的工作流实例。

public:
 void Load();
public void Load ();
member this.Load : unit -> unit
Public Sub Load ()

例外

工作流运行时引擎未运行。

示例

下面的示例演示如何加载先前卸载的 WorkflowInstance 对象。

// Create a WorkflowRuntime object
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Create a new instance of the out-of-box SqlWorkflowPersistenceService
SqlWorkflowPersistenceService persistenceService =
   new SqlWorkflowPersistenceService(
   "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;");
// Add the service to the runtime
workflowRuntime.AddService(persistenceService);
// Create a WorkflowInstance object
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(Workflow1));
// Start the workflow instance
workflowInstance.Start();
//Unload the instance
workflowInstance.Unload();
//Reload the previously unloaded instance
workflowInstance.Load();
' Create a WorkflowRuntime object
Dim workflowRuntime As New WorkflowRuntime()
' Create a new instance of the out-of-box SqlWorkflowPersistenceService
Dim persistenceService As _
   New SqlWorkflowPersistenceService( _
   "Initial Catalog=SqlPersistenceServiceData Source=localhostIntegrated Security=SSPI")
' Add the service to the runtime
workflowRuntime.AddService(persistenceService)
' Create a WorkflowInstance object
Dim workflowInstance As WorkflowInstance = workflowRuntime.CreateWorkflow(GetType(Workflow1))
' Start the workflow instance
workflowInstance.Start()
'Unload the instance
workflowInstance.Unload()
'Reload the previously unloaded instance
workflowInstance.Load()

注解

Load 是同步的,如果工作流实例可以加载,则 Load 将在工作流实例被加载到内存并由工作流运行时引擎计划后返回。 运行时将在持久性服务恢复内存中的工作流之后与工作流运行时引擎计划实例之前引发 WorkflowLoaded 事件。

适用于