WorkflowRuntime.StartRuntime 메서드

정의

워크플로 런타임 엔진과 워크플로 런타임 엔진 서비스를 시작합니다.

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

예외

둘 이상의 서비스 워크플로 CommitWorkBatch 서비스가 이 WorkflowRuntime에 등록된 경우

또는

둘 이상의 스케줄러 서비스가 이 WorkflowRuntime에 등록된 경우

또는

둘 이상의 지속성 서비스가 이 WorkflowRuntime에 등록된 경우

예제

다음 코드 예제에서는 워크플로 호스트에서 WorkflowRuntime 기능을 사용하는 방법을 보여 줍니다. 이 코드에서는 StartRuntimeWorkflowRuntime 인스턴스를 만들고 WorkflowRuntime를 호출하여 서비스를 런타임에 추가한 후 AddService을 호출합니다. 또한 다른 처리가 발생하기 전에 StartRuntime을 호출합니다.

일부인이 코드 예제는 워크플로 취소 하면 샘플입니다.

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 클래스에서 파생된 모든 서비스를 시작합니다. 각 핵심 서비스 중 하나만 있어야: 워크플로 CommitWorkBatch 에서 파생 된 서비스를 WorkflowCommitWorkBatchService 에서 파생 된 기본 클래스 및 scheduler 서비스는 WorkflowSchedulerService 기본 클래스입니다. 이러한 핵심 서비스 중 하나 또는 모두 없는 경우 워크플로 런타임 엔진에서 해당 기본 서비스를 제공 합니다. DefaultWorkflowCommitWorkBatchService 워크플로에 대 한 CommitWorkBatch 서비스 및 DefaultWorkflowSchedulerService scheduler 서비스에 대 한 합니다. 지속성 서비스는 선택 사항이지만 하나의 지속성 서비스만 있을 수 있습니다. 서비스 구성의 유효성을 검사한 후 StartRuntimeStart 클래스에서 파생된 모든 서비스에서 WorkflowRuntimeService를 호출합니다. 마지막으로 워크플로 런타임 엔진은 IsStarted를 설정하고 Started 이벤트를 발생시킵니다.

워크플로 런타임 엔진이 시작된 후에는 핵심 서비스를 추가하거나 제거할 수 없습니다. 핵심 서비스는 WorkflowSchedulerService 클래스, WorkflowCommitWorkBatchService 클래스, WorkflowPersistenceService 클래스 및 TrackingService 클래스에서 파생된 서비스입니다. 워크플로 런타임 엔진이 실행되는 동안 StartRuntime을 호출하면 작업이 수행되지 않습니다.

적용 대상