Edit

Bagikan melalui


WorkflowRuntime.RemoveService(Object) Method

Definition

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)

Parameters

service
Object

An object that represents the service to remove.

Exceptions

service is a null reference (Nothing in Visual Basic).

The WorkflowRuntime is already disposed of.

The workflow run-time engine has started (IsStarted is true) and service is a core service.

-or-

service is not registered with the workflow run-time engine.

Examples

In 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)

Remarks

You cannot remove a core service while the workflow run-time engine is running (IsStarted is true). Core services are services that derive from the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, the WorkflowPersistenceService class, or the TrackingService class. If service derives from the WorkflowRuntimeService class, RemoveService calls the Stop method implemented by service.

Applies to