Partager via


WorkflowRuntime.WorkflowCompleted Événement

Définition

Se produit lorsqu'une instance de workflow a été effectuée.

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) 

Type d'événement

Exemples

L'exemple de code suivant montre comment utiliser les fonctionnalités WorkflowRuntime d'un hôte de workflow. Le code associe l'événement WorkflowCompleted à un gestionnaire d'événements, méthode qui est nommée OnWorkflowCompleted.

Cet exemple de code fait partie de l’exemple d’annulation d’un flux de travail .

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

Remarques

WorkflowCompleted est déclenché après que l'instance de workflow ait été effectuée mais avant qu'elle ait été invalidée dans la mémoire.

Pour l'événement WorkflowPersisted, l'expéditeur contient l'objet WorkflowRuntime et l'objet WorkflowCompletedEventArgs contient l'objet WorkflowInstance et ses paramètres de sortie.

Pour plus d’informations sur la gestion des événements, consultez Gestion et déclenchement d’événements.

S’applique à