WorkflowRuntime.WorkflowCompleted イベント

定義

ワークフロー インスタンスが完了すると発生します。

public:
 event EventHandler<System::Workflow::Runtime::WorkflowCompletedEventArgs ^> ^ WorkflowCompleted;
public event EventHandler<System.Workflow.Runtime.WorkflowCompletedEventArgs> WorkflowCompleted;
member this.WorkflowCompleted : EventHandler<System.Workflow.Runtime.WorkflowCompletedEventArgs> 
Public Custom Event WorkflowCompleted As EventHandler(Of WorkflowCompletedEventArgs) 
Public Event WorkflowCompleted As EventHandler(Of WorkflowCompletedEventArgs) 

イベントの種類

次のコード例は、ワークフローのホストから WorkflowRuntime の機能を使用する方法を示しています。 このコードでは、WorkflowCompleted をイベント ハンドラーである OnWorkflowCompleted という名前のメソッドに関連付けています。

このコード例は、ワークフローの 取り消しサンプルの 一部です。

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

注釈

WorkflowCompleted が発生するタイミングは、ワークフロー インスタンスが完了してからメモリ内のインスタンスが無効化されるまでの間です。

WorkflowPersisted イベントでは、送信元に WorkflowRuntime が含まれ、WorkflowCompletedEventArgs には WorkflowInstance とその出力パラメーターが格納されます。

イベントの処理の詳細については、「イベントの 処理と発生」を参照してください。

適用対象