共用方式為


WorkflowRuntime.RemoveService(Object) 方法

定義

從工作流程執行階段引擎中移除指定的服務。

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

參數

service
Object

物件,表示要移除的服務。

例外狀況

service 為 null 參考 (在 Visual Basic 中為 Nothing)。

工作流程執行階段引擎已啟動 (IsStartedtrue ),而且 service 是核心服務。

-或-

service 尚未向工作流程執行階段引擎註冊。

範例

在下列範例中,將在 SqlWorkflowPersistenceService 中加入並移除 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 時,您無法移除核心服務。 核心服務是衍生自 WorkflowSchedulerService 類別、WorkflowCommitWorkBatchService 類別、WorkflowPersistenceService 類別和 TrackingService 類別的服務。 如果 service 衍生自 WorkflowRuntimeService 類別,RemoveService 會呼叫由 Stop 實作的 service 方法。

適用於