WorkflowRuntimeService.OnStopped WorkflowRuntimeService.OnStopped WorkflowRuntimeService.OnStopped WorkflowRuntimeService.OnStopped Method


在衍生類別中覆寫時,代表在工作流程執行階段引擎引發 Stopped 事件時將呼叫的方法。When overridden in a derived class, represents the method that will be called when the workflow runtime engine raises the Stopped event.

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


WorkflowRuntimeService 類別會實作兩階段的停止機制,因此在工作流程執行階段引擎叫用執行階段引擎服務的 Stop 方法後,這些服務仍可視需要保留部分功能以支援其他服務的關閉。The WorkflowRuntimeService class implements a two-phase stopping mechanism so that workflow runtime engine services may retain some functionality after their Stop method is invoked by the workflow runtime engine in order that they may, if necessary, support the shutdown of other services. 工作流程執行階段引擎呼叫所有它的工作流程執行階段引擎服務的 Stop 方法後,會引發 WorkflowRuntime.Stopped 事件。After the workflow runtime engine has called the Stop method of all of its workflow runtime engine services, it raises the WorkflowRuntime.Stopped event. OnStopped 事件引發時,您可以覆寫 WorkflowRuntime.Stopped 方法以提供您的服務所需的任何最後關閉功能。You can override the OnStopped method to provide any final shutdown functionality required by your service when the WorkflowRuntime.Stopped event is raised. WorkflowRuntime.Stopped 事件訂閱和取消訂閱的機能是在內部處理。The mechanics of subscribing and unsubscribing from the WorkflowRuntime.Stopped event is handled internally.


如果在工作流程執行階段引擎執行時,呼叫 WorkflowRuntimeService 來從工作流程執行階段引擎中移除您的 RemoveService,工作流程執行階段引擎將呼叫您服務上的 StopIf your WorkflowRuntimeService is removed from the workflow runtime engine by a call to RemoveService while the workflow runtime engine is running, the workflow runtime engine will call Stop on your service. 但在此情況中,將不會對您的服務呼叫 OnStopped 方法。However, in this situation, the OnStopped method will not be called for your service. 因此,您的服務可能必須執行它通常由 OnStopped 方法內部的 Stop 中執行的最後關閉功能。Therefore, your service may have to perform any final shutdown that it would ordinarily perform in OnStopped from inside the Stop method. 您可以測試 IsStarted 以判斷工作流程執行階段引擎是否正在執行。You can test IsStarted to determine whether the workflow runtime engine is running.

State 在叫用 Stopped 前是設定為 OnStoppedState is set to Stopped before OnStopped is invoked. 預設的 OnStopped 實作不會執行任何動作。The default implementation of OnStopped performs no action.