WorkflowRuntime.StartRuntime 메서드

정의

워크플로 런타임 엔진과 워크플로 런타임 엔진 서비스를 시작합니다.Starts the workflow run-time engine and the workflow run-time engine services.

public:
 void StartRuntime();
public void StartRuntime ();
member this.StartRuntime : unit -> unit
Public Sub StartRuntime ()

예외

WorkflowRuntime이 삭제된 경우The WorkflowRuntime is disposed.

둘 이상의 서비스 워크플로 CommitWorkBatch 서비스가 이 WorkflowRuntime에 등록된 경우There is more than one service workflow CommitWorkBatch service registered with this WorkflowRuntime.

또는-or- 둘 이상의 스케줄러 서비스가 이 WorkflowRuntime에 등록된 경우There is more than one scheduler service registered with this WorkflowRuntime.

또는-or- 둘 이상의 지속성 서비스가 이 WorkflowRuntime에 등록된 경우There is more than one persistence service registered with this WorkflowRuntime.

예제

다음 코드 예제에서는 워크플로 호스트에서 WorkflowRuntime 기능을 사용하는 방법을 보여 줍니다.The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. 이 코드에서는 StartRuntimeWorkflowRuntime 인스턴스를 만들고 WorkflowRuntime를 호출하여 서비스를 런타임에 추가한 후 AddService을 호출합니다.The code calls the StartRuntime after the WorkflowRuntime creates a WorkflowRuntime instance and after it calls AddService to add services to the runtime. 또한 다른 처리가 발생하기 전에 StartRuntime을 호출합니다.It also calls StartRuntime before any other processing occurs.

일부인이 코드 예제는 워크플로 취소 하면 샘플입니다.This code example is part of the Canceling 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

설명

이 메서드는 올바른 핵심 서비스 집합이 있는지 확인한 다음 WorkflowRuntimeService 클래스에서 파생된 모든 서비스를 시작합니다.This method verifies that a valid set of core services exists and then starts any services that derive from the WorkflowRuntimeService class. 각 핵심 서비스 중 하나만 있어야: 워크플로 CommitWorkBatch 에서 파생 된 서비스를 WorkflowCommitWorkBatchService 에서 파생 된 기본 클래스 및 scheduler 서비스는 WorkflowSchedulerService 기본 클래스입니다.There must be one and only one of each of the following core services: a workflow CommitWorkBatch service derived from the WorkflowCommitWorkBatchService base class and a scheduler service derived from the WorkflowSchedulerService base class. 이러한 핵심 서비스 중 하나 또는 모두 없는 경우 워크플로 런타임 엔진에서 해당 기본 서비스를 제공 합니다. DefaultWorkflowCommitWorkBatchService 워크플로에 대 한 CommitWorkBatch 서비스 및 DefaultWorkflowSchedulerService scheduler 서비스에 대 한 합니다.If either or both of these core services are missing, the workflow run-time engine supplies the appropriate default service: DefaultWorkflowCommitWorkBatchService for the workflow CommitWorkBatch service and DefaultWorkflowSchedulerService for the scheduler service. 지속성 서비스는 선택 사항이지만 하나의 지속성 서비스만 있을 수 있습니다.A persistence service is optional, but there can be at most only one persistence service present. 서비스 구성의 유효성을 검사한 후 StartRuntimeStart 클래스에서 파생된 모든 서비스에서 WorkflowRuntimeService를 호출합니다.After it has validated the service configuration, StartRuntime calls Start on all of the services that are derived from the WorkflowRuntimeService class. 마지막으로 워크플로 런타임 엔진은 IsStarted를 설정하고 Started 이벤트를 발생시킵니다.Finally, the workflow run-time engine sets IsStarted and raises the Started event.

워크플로 런타임 엔진이 시작된 후에는 핵심 서비스를 추가하거나 제거할 수 없습니다.You cannot add or remove core services after the workflow run-time engine is started. 핵심 서비스는 WorkflowSchedulerService 클래스, WorkflowCommitWorkBatchService 클래스, WorkflowPersistenceService 클래스 및 TrackingService 클래스에서 파생된 서비스입니다.Core services are services that derive from the WorkflowSchedulerService class, the WorkflowCommitWorkBatchService class, the WorkflowPersistenceService class, or the TrackingService class. 워크플로 런타임 엔진이 실행되는 동안 StartRuntime을 호출하면 작업이 수행되지 않습니다.If you call StartRuntime while the workflow run-time engine is running, no action is performed.

적용 대상