WorkflowEventArgs Classe

Définition

Attention

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

Fournit des données pour les événements de workflow.Provides data for workflow events.

public ref class WorkflowEventArgs : EventArgs
public class WorkflowEventArgs : EventArgs
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class WorkflowEventArgs : EventArgs
type WorkflowEventArgs = class
    inherit EventArgs
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type WorkflowEventArgs = class
    inherit EventArgs
Public Class WorkflowEventArgs
Inherits EventArgs
Héritage
WorkflowEventArgs
Dérivé
Attributs

Exemples

L'exemple de code suivant montre comment obtenir un objet WorkflowInstance à l'aide de la propriété WorkflowInstance lorsqu'une méthode de gestion d'événements est appelée.The following code example demonstrates how to obtain a WorkflowInstance object using the WorkflowInstance property when an event handler method is called. Lorsque l'événement WorkflowIdled se produit, la méthode OnWorkflowIdled définie dans cet exemple est appelée.When the WorkflowIdled event occurs, the OnWorkflowIdled method defined in this example is called. Il détermine quel workflow est désactivé à l’aide de la propriété WorkflowInstance puis obtient une collection d’éléments en file d’attente pour l’instance de workflow en appelant la méthode GetWorkflowQueueData.It determines which workflow is idled using the WorkflowInstance property and then gets a collection of queued items for the workflow instance by calling the GetWorkflowQueueData method. Le code itère au sein de la collection pour déterminer quelle activité attend l’événement ayant désactivé le workflow.The code iterates over the collection to determine which activity is waiting for the event that idled the workflow. Il envoie alors une exception à la file d'attente de workflow à l'aide de la méthode EnqueueItem avec le nom de l'élément de la file d'attente de l'événement.It then sends an exception to the workflow queue using the EnqueueItem method along with the name of the event queue item.

Cet exemple de code fait partie de l'exemple de Kit de développement logiciel Canceling a Workflow (SDK) du fichier Program.cs.This code example is part of the Canceling a Workflow SDK Sample from the Program.cs file. Pour plus d’informations, consultez annulation d’un flux de travail.For more information, see Canceling a Workflow.

static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
{
    WorkflowInstance workflow = e.WorkflowInstance;

    Console.WriteLine("\n...waiting for 3 seconds... \n");
    Thread.Sleep(3000);

    // what activity is blocking the workflow
    ReadOnlyCollection<WorkflowQueueInfo> wqi = workflow.GetWorkflowQueueData();
    foreach (WorkflowQueueInfo q in wqi)
    {
        EventQueueName eq = q.QueueName as EventQueueName;
        if (eq != null)
        {
            // get activity that is waiting for event
            ReadOnlyCollection<string> blockedActivity = q.SubscribedActivityNames;
            Console.WriteLine("Host: Workflow is blocked on " + blockedActivity[0]);

            // this event is never going to arrive eg. employee left the company
            // lets send an exception to this queue
            // it will either be handled by exception handler that was modeled in workflow
            // or the runtime will unwind running compensation handlers and exit the workflow
            Console.WriteLine("Host: This event is not going to arrive");
            Console.WriteLine("Host: Cancel workflow with unhandled exception");
            workflow.EnqueueItem(q.QueueName, new Exception("ExitWorkflowException"), null, null);
        }
    }
}
Shared Sub OnWorkflowIdled(ByVal sender As Object, ByVal e As WorkflowEventArgs)
    Dim workflow As WorkflowInstance = e.WorkflowInstance

    Console.WriteLine(vbCrLf + "...waiting for 3 seconds... " + vbCrLf)
    Thread.Sleep(3000)

    ' what activity is blocking the workflow
    Dim wqi As ReadOnlyCollection(Of WorkflowQueueInfo) = workflow.GetWorkflowQueueData()
    For Each q As WorkflowQueueInfo In wqi

        Dim eq As EventQueueName = TryCast(q.QueueName, EventQueueName)

        If eq IsNot Nothing Then
            ' get activity that is waiting for event
            Dim blockedActivity As ReadOnlyCollection(Of String) = q.SubscribedActivityNames
            Console.WriteLine("Host: Workflow is blocked on " + blockedActivity(0))

            ' this event is never going to arrive eg. employee left the company
            ' lets send an exception to this queue
            ' it will either be handled by exception handler that was modeled in workflow
            ' or the runtime will unwind running compensation handlers and exit the workflow
            Console.WriteLine("Host: This event is not going to arrive")
            Console.WriteLine("Host: Cancel workflow with unhandled exception")
            workflow.EnqueueItem(q.QueueName, New Exception("ExitWorkflowException"), Nothing, Nothing)
        End If
    Next
End Sub

Remarques

Notes

Ce document décrit les types et les espaces de noms qui sont obsolètes.This material discusses types and namespaces that are obsolete. Pour plus d’informations, consultez Types dépréciés dans Windows Workflow Foundation 4.5.For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

Les événements de workflow sont associés à une instance de workflow.Workflow events are associated with a workflow instance. Une WorkflowEventArgs contient la WorkflowInstance associée à l'événement de workflow.A WorkflowEventArgs contains the WorkflowInstance associated with the workflow event. Un WorkflowEventArgs ou un objet qui dérive de la classe WorkflowEventArgs fournit les données pour tous les événements de flux de travail dans la classe WorkflowRuntime.A WorkflowEventArgs or an object that derives from the WorkflowEventArgs class provides the data for all of the workflow events in the WorkflowRuntime class. WorkflowEventArgs est la classe de base des classes WorkflowCompletedEventArgs, WorkflowSuspendedEventArgs et WorkflowTerminatedEventArgs.WorkflowEventArgs is the base class for WorkflowCompletedEventArgs, WorkflowSuspendedEventArgs, and WorkflowTerminatedEventArgs.

Propriétés

WorkflowInstance

Obtient l'instance de workflow associée à l'événement de workflow.Gets the workflow instance associated with the workflow event.

Méthodes

Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.Determines whether the specified object is equal to the current object.

(Hérité de Object)
GetHashCode()

Fait office de fonction de hachage par défaut.Serves as the default hash function.

(Hérité de Object)
GetType()

Obtient le Type de l'instance actuelle.Gets the Type of the current instance.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Object actuel.Creates a shallow copy of the current Object.

(Hérité de Object)
ToString()

Retourne une chaîne qui représente l'objet actuel.Returns a string that represents the current object.

(Hérité de Object)

S’applique à