WorkflowRuntime.StartRuntime メソッド

定義

ワークフロー ランタイム エンジンとワークフロー ランタイム エンジンのサービスを開始します。

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

例外

WorkflowRuntime は破棄されています。

この WorkflowRuntime に登録されているサービス ワークフロー CommitWorkBatch サービスが複数あります。

- または -

この 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 派生したスケジューラ サービスの各コア サービス WorkflowSchedulerService の 1 つだけが必要です。 これらのコア サービスのいずれかまたは両方が見つからない場合、ワークフロー ランタイム エンジンは、ワークフロー サービスとDefaultWorkflowSchedulerServiceスケジューラ サービス DefaultWorkflowCommitWorkBatchServiceCommitWorkBatchに適切な既定のサービスを提供します。 永続性サービスはオプションですが、存在できる永続性サービスは 1 つまでです。 サービス構成を検証した後、StartRuntime は、Start クラスから派生したすべてのサービスについて WorkflowRuntimeService を呼び出します。 最後に、ワークフロー ランタイム エンジンは IsStarted を設定し、Started イベントを発生させます。

ワークフロー ランタイム エンジンが起動した後は、コア サービスを追加することも削除することもできません。 コア サービスは、WorkflowSchedulerServiceクラス、WorkflowCommitWorkBatchServiceクラス、WorkflowPersistenceServiceクラス、または TrackingService クラスから派生したサービスです。 ワークフロー ランタイム エンジンの実行中に StartRuntime を呼び出した場合、アクションは何も実行されません。

適用対象