WorkflowRuntime.RemoveService(Object) 方法

定義

從工作流程執行階段引擎中移除指定的服務。Removes the specified service from the workflow run-time engine.

public:
 void RemoveService(System::Object ^ service);
public void RemoveService (object service);
member this.RemoveService : obj -> unit
Public Sub RemoveService (service As Object)

參數

service
Object

物件,表示要移除的服務。An object that represents the service to remove.

例外狀況

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

已經處置 WorkflowRuntimeThe WorkflowRuntime is already disposed of.

工作流程執行階段引擎已啟動 (IsStartedtrue ),而且 service 是核心服務。The workflow run-time engine has started (IsStarted is true) and service is a core service.

-或--or- service 尚未向工作流程執行階段引擎註冊。service is not registered with the workflow run-time engine.

範例

在下列範例中,將在 SqlWorkflowPersistenceService 中加入並移除 WorkflowRuntimeIn the following example, a SqlWorkflowPersistenceService is added and removed from the WorkflowRuntime.

// Create a new workflow runtime
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);
// Start the runtime
workflowRuntime.StartRuntime();
// Stop the runtime
workflowRuntime.StopRuntime();
// Remove the service from the runtime
workflowRuntime.RemoveService(persistenceService);
' Create a new workflow runtime
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)
' Start the runtime
workflowRuntime.StartRuntime()
' Stop the runtime
workflowRuntime.StopRuntime()
' Remove the service from the runtime
workflowRuntime.RemoveService(persistenceService)

備註

當工作流程執行時間引擎正在執行(IsStartedtrue)時,您無法移除核心服務。You cannot remove a core service while the workflow run-time engine is running (IsStarted is true). 核心服務是衍生自 WorkflowSchedulerService 類別、WorkflowCommitWorkBatchService 類別、WorkflowPersistenceService 類別和 TrackingService 類別的服務。Core services are services that derive from the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, the WorkflowPersistenceService class, or the TrackingService class. 如果 service 衍生自 WorkflowRuntimeService 類別,RemoveService 會呼叫由 Stop 實作的 service 方法。If service derives from the WorkflowRuntimeService class, RemoveService calls the Stop method implemented by service.

適用於