WorkflowRuntime.Stopped WorkflowRuntime.Stopped WorkflowRuntime.Stopped WorkflowRuntime.Stopped Event


在工作流程執行階段引擎停止時發生。Occurs when the workflow run-time engine is stopped.

 event EventHandler<System::Workflow::Runtime::WorkflowRuntimeEventArgs ^> ^ Stopped;
public event EventHandler<System.Workflow.Runtime.WorkflowRuntimeEventArgs> Stopped;
member this.Stopped : EventHandler<System.Workflow.Runtime.WorkflowRuntimeEventArgs> 
Public Event Stopped As EventHandler(Of WorkflowRuntimeEventArgs) 


在下列範例中,會將事件處理常式加入至 StoppedWorkflowRuntime 事件中。In the following example, an event handler is added to the Stopped event of the WorkflowRuntime. 在這個範例中,處理常式是列印簡易訊息至主控台的匿名方法。In this example, the handler is an anonymous method that prints a simple message to the console.

// Create a new workflow runtime
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Add an anonymous method as the event handler for the Stopped event.
workflowRuntime.Stopped += new EventHandler<WorkflowRuntimeEventArgs>(
    delegate { Console.WriteLine("Workflow runtime stopped."); });
' Create a new workflow runtime
Dim workflowRuntime As New WorkflowRuntime()
' Add a method as the event handler for the Stopped event.
AddHandler workflowRuntime.Stopped, AddressOf RuntimeStopped


StopRuntime 方法會在叫用以其衍生自 Stopped 類別的每個服務實作的 Stop 方法後,引發 WorkflowRuntimeService 事件。The StopRuntime method raises the Stopped event after it has invoked the Stop method implemented by each of its services that derive from the WorkflowRuntimeService class. 這些工作流程執行階段引擎服務的停止順序不一定,而且這些服務的其中一些服務可能需要保留一些其他服務所依賴的功能,直到其他服務停止為止。There is no guarantee about the order in which these workflow run-time engine services are stopped, and some of these services may need to preserve some functionality that is relied on by other services until they too are stopped. 這類服務可以覆寫 WorkflowRuntimeService.OnStopped 方法,以在引發 Stopped 事件時執行任何剩餘的關閉邏輯。Such services can override the WorkflowRuntimeService.OnStopped method to perform any residual shutdown logic when the Stopped event is raised.

如需處理事件的詳細資訊,請參閱處理和引發事件For more information about handling events, see Handling and raising events.