WorkflowRuntimeService.Stop 方法

定義

在衍生類別中覆寫時,停止服務並將 State 變更為 StoppingWhen overridden in a derived class, stops the service and changes the State to Stopping.

protected public:
 virtual void Stop();
protected internal virtual void Stop ();
abstract member Stop : unit -> unit
override this.Stop : unit -> unit
Protected Friend Overridable Sub Stop ()

例外狀況

Runtime 為 null 參考 (在 Visual Basic 中為 Nothing)。Runtime is a null reference (Nothing in Visual Basic).

-或--or- 服務尚未啟動。The service has not yet been started.

備註

呼叫 Stop 時,工作流程執行階段引擎會在每個衍生自 WorkflowRuntimeService 類別的服務上叫用 StopRuntimeStop is invoked by the workflow runtime engine on all of its services that derive from the WorkflowRuntimeService class when StopRuntime is called. 呼叫 Stop 從工作流程執行階段引擎移除工作流程執行階段引擎服務時,工作流程執行階段引擎也會叫用 RemoveServiceStop is also invoked by the workflow runtime engine when a workflow runtime engine service is removed from the workflow runtime engine by a call to RemoveService. Stop 的預設實作會追蹤服務是否已啟動,並使用這項資訊擲回適當的例外狀況 (如果服務在它啟動之前已停止)。The default implementation of Stop tracks whether the service has been started and uses this information to throw the appropriate exception if the service is stopped before it is started.

您可以透過覆寫此方法,提供由工作流程執行階段引擎停止您的服務所需的額外方法,You can provide additional functionality necessary to have your service stopped by the workflow runtime engine by overriding this method. 但是,在服務上呼叫 Stop 時,並不保證將會停止哪些服務或哪些服務仍在執行中 (如果有的話)。There is no guarantee about which, if any, services will be stopped or running when Stop is called on your service. 工作流程執行階段引擎會在呼叫所有它的工作流程執行階段引擎服務的 WorkflowRuntime.Stopped 方法後,引發 Stop 事件。The workflow runtime engine raises the WorkflowRuntime.Stopped event after it has called the Stop method of all of its workflow runtime engine services. 您的服務可能需要保留一些剩餘功能以支援其他服務,直到工作流程執行階段引擎叫用所有工作流程執行階段引擎的停止方法為止。Your service may need to retain some residual functionality to support other services until all the workflow runtime engine services have had their stop methods invoked by the workflow runtime engine. 如果您的服務必須保留這類功能,您可以覆寫 OnStopped 方法,以便在 WorkflowRuntime.Stopped 事件引發時,執行完成停止服務所需的任何額外動作。If your service must retain such functionality, you can override the OnStopped method to perform any additional action required to finish stopping your service when the WorkflowRuntime.Stopped event is raised.

注意

如果在工作流程執行階段引擎執行時,呼叫 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 additional shutdown functionality 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.

Stop 應該只能由工作流程執行階段引擎呼叫。Stop should only be called by the workflow runtime engine.

適用於