WorkflowRuntime.AddService(Object) WorkflowRuntime.AddService(Object) WorkflowRuntime.AddService(Object) WorkflowRuntime.AddService(Object) Method

정의

지정된 서비스를 워크플로 런타임 엔진에 추가합니다.Adds the specified service to the workflow run-time engine.

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

매개 변수

service
Object Object Object Object

추가할 서비스를 나타내는 개체입니다.An object that represents the service to add.

예외

service이 null 참조(Visual Basic의 경우 Nothing)인 경우service is a null reference (Nothing in Visual Basic).

service가 워크플로 런타임 엔진에 이미 등록된 경우service is already registered with the workflow run-time engine.

또는-or- service가 핵심 서비스이고 워크플로 런타임 엔진이 이미 실행 중인 경우(IsStartedtrue인 경우)service is a core service and the workflow run-time engine is already running (IsStarted is true).

예제

다음 코드 예제에서는 워크플로 호스트에서 WorkflowRuntime 기능을 사용하는 방법을 보여 줍니다.The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. AddService 메서드를 사용하여 ExternalDataExchangeServiceSqlWorkflowPersistenceService를 워크플로 런타임 엔진에 추가하는 방법의 예제를 제공합니다.It provides example of how to use the AddService method to add an ExternalDataExchangeService and SqlWorkflowPersistenceService to the workflow run-time engine.

일부인이 코드 예제는 워크플로 취소 샘플입니다.This code example is part of the Cancelling a Workflow sample.

static void Main()
{
    string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;";

    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
    {
        ExternalDataExchangeService dataService = new ExternalDataExchangeService();
        workflowRuntime.AddService(dataService);
        dataService.AddService(expenseService);

        workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString));
        workflowRuntime.StartRuntime();

        workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
        workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
        workflowRuntime.WorkflowIdled += OnWorkflowIdled;
        workflowRuntime.WorkflowAborted += OnWorkflowAborted;

        Type type = typeof(SampleWorkflow1);
        WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
        workflowInstance.Start();

        waitHandle.WaitOne();

        workflowRuntime.StopRuntime();
    }
}
Shared Sub Main()
    Dim connectionString As String = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"
    Using workflowRuntime As New WorkflowRuntime()
        Dim dataService As New ExternalDataExchangeService()
        workflowRuntime.AddService(dataService)
        dataService.AddService(expenseService)

        workflowRuntime.AddService(New SqlWorkflowPersistenceService(connectionString))


        AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
        AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated
        AddHandler workflowRuntime.WorkflowIdled, AddressOf OnWorkflowIdled
        AddHandler workflowRuntime.WorkflowAborted, AddressOf OnWorkflowAborted


        Dim workflowInstance As WorkflowInstance
        workflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
        workflowInstance.Start()

        waitHandle.WaitOne()

        workflowRuntime.StopRuntime()
    End Using
End Sub

설명

핵심 서비스를 추가하여 워크플로 런타임 엔진을 구성할 수 있습니다.You can configure the workflow run-time engine by adding core services. 핵심 서비스는 서비스 기본 클래스인 WorkflowSchedulerService 클래스, WorkflowCommitWorkBatchService 클래스, WorkflowPersistenceService 클래스 및 TrackingService 클래스에서 파생된 서비스입니다.Core services are those that derive from any of the following service base classes: the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, the WorkflowPersistenceService class, and the TrackingService class. 핵심 서비스 워크플로 런타임 엔진이 실행 되 고 있지 않으면 추가할 수 있습니다. 즉, IsStartedfalse합니다.Core services can only be added when the workflow run-time engine is not running; that is, when IsStarted is false. WorkflowRuntime은 호스트에서 실행 중인 애플리케이션이나 다른 워크플로에서 사용할 수 있는 다른 서비스에 대한 스토리지 컨테이너로 사용될 수도 있습니다.The WorkflowRuntime can also be used as a storage container for other services that can be used by other workflows or by applications running on a host. 워크플로 런타임 엔진이 시작된 후 WorkflowRuntimeService 클래스에서 파생된 비핵심 서비스를 추가하면 AddService가 해당 서비스에 의해 구현된 Start 메서드를 호출합니다.If you add a non-core service that derives from the WorkflowRuntimeService class after the workflow run-time engine has been started, AddService calls the Start method implemented by that service.

참고

AddServiceType이 동일한 두 개의 서비스를 WorkflowRuntime에 추가할 수 없다는 제한을 적용합니다.AddService enforces the restriction that no two services of the same Type can be added to the WorkflowRuntime. 그러나 동일한 기본 클래스에서 파생된 서비스는 여러 개 추가할 수 있습니다.However, you can add multiple services that derive from the same base class. WorkflowRuntime의 서비스 기본 클래스인 WorkflowSchedulerService 클래스, WorkflowCommitWorkBatchService 클래스 및 WorkflowPersistenceService 클래스에서 각각 하나의 서비스만 파생될 수 있습니다.There can be only one service derived from each of the following service base classes in the WorkflowRuntime: the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, and the WorkflowPersistenceService class. 이러한 클래스 중 하나에서 파생된 여러 서비스(예: 두 개의 지속성 서비스)를 추가하면 StartRuntimeInvalidOperationException을 throw합니다.If you add multiple services derived from one of these classes, for example two persistence services, StartRuntime throws an InvalidOperationException.

적용 대상