WorkflowRuntimeService.OnStarted 方法

定义

在派生类中重写时,表示将在工作流运行时引擎引发 Started 事件时调用的方法。When overridden in a derived class, represents the method that will be called when the workflow runtime engine raises the Started event.

protected:
 virtual void OnStarted();
protected virtual void OnStarted ();
abstract member OnStarted : unit -> unit
override this.OnStarted : unit -> unit
Protected Overridable Sub OnStarted ()

注解

WorkflowRuntimeService 类实现两阶段启动机制,这样,当工作流运行时引擎为其所有工作流运行时引擎服务调用 Start 方法之后,工作流运行时引擎服务可以执行任何依赖于其他服务的初始化。The WorkflowRuntimeService class implements a two-phase starting mechanism so that workflow runtime engine services may perform any initialization that depends on other services after the workflow runtime engine has invoked the Start method for all of its workflow runtime engine services. 在工作流运行时引擎调用其所有工作流运行时引擎服务的 Start 方法后,将引发 WorkflowRuntime.Started 事件。After the workflow runtime engine has called the Start method of all of its workflow runtime engine services, it raises the WorkflowRuntime.Started event. 可以重写 OnStarted 方法,在引发 WorkflowRuntime.Started 事件时提供服务所需的任何最终启动功能。You can override the OnStarted method to provide any final startup functionality required by your service when the WorkflowRuntime.Started event is raised. WorkflowRuntime.Started 事件的订阅和取消订阅机制在内部进行处理。The mechanics of subscribing and unsubscribing from the WorkflowRuntime.Started event is handled internally.

备注

如果在启动工作流运行时引擎之后,通过调用 AddService 将您的服务添加到工作流运行时引擎,则工作流运行时引擎将在该服务上调用 StartIf your service is added to the workflow runtime engine by a call to AddService after the workflow runtime engine has already been started, the workflow runtime engine will call Start on your service. 不过,由于在这种情况下已经发生 Started 事件,因此,您的服务可能需要在 OnStarted 方法内部执行任何通常在 Start 中执行的初始化。However, in this situation, the Started event has already occurred, therefore, your service may have to perform any initialization that it would ordinarily perform in OnStarted from inside the Start method. 可以测试 IsStarted,确定工作流运行时引擎是否已启动。You can test IsStarted to determine whether the workflow runtime engine has been started.

在调用 State 之前,Started 设置为 OnStartedState is set to Started before OnStarted is invoked. OnStarted 的默认实现不执行任何操作。The default implementation of OnStarted performs no action.

适用于