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 является неопределенной ссылкой (Nothing в Visual Basic).

Объект WorkflowRuntime уже удален.

Механизм среды выполнения рабочих процессов запущен (свойство IsStarted имеет значение true), и 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)

Комментарии

Вы не можете удалить базовую службу во время выполнения рабочего процесса (IsStarted имеет значение true). Базовые службы — это службы, производные от классов WorkflowSchedulerService, WorkflowCommitWorkBatchService, WorkflowPersistenceService или TrackingService. Если служба service является производной от класса WorkflowRuntimeService, то метод RemoveService вызывает метод Stop, реализованный service.

Применяется к