EventDrivenActivity Class
Wraps an Activity whose execution is initialized by an event. This class cannot be inherited.
Assembly: System.Workflow.Activities (in System.Workflow.Activities.dll)
It is a CompositeActivity that is used to handle an event; typically it can be raised from the host or by the runtime in response to a delay timer expiring. EventDrivenActivity is inherited from SequenceActivity; therefore, it is a sequence that has the additional restriction that the first activity should be an IEventActivity.
The EventDrivenActivity is a CompositeActivity, which means the EventDrivenActivity can contain other activities. The EventDrivenActivity is similar to the SequenceActivity activity, with some additional characteristics.
An EventDrivenActivity must have a parent that is either a ListenActivity, StateActivity, or StateMachineWorkflowActivity.
The first child of an EventDrivenActivity activity must be an activity that inherits from IEventActivity. All subsequent children can be activities of any type. The IEventActivity blocks and waits for the pending occurrence of some events, such as starting a timer or the arrival of a message. When the event occurs, the IEventActivity finishes running and then all subsequent activities are executed.
When the StateMachineWorkflowActivity contains an EventDrivenActivity, the EventDrivenActivity has some restrictions:
The EventDrivenActivity may contain one, and only one, activity of type IEventActivity.
The HandleExternalEventActivity must be the first child activity. An HandleExternalEventActivity cannot be in the event handler for a child activity and cannot be a child to the EventDrivenActivity if the HandleExternalEventActivity is not the first child.
As long as the first activity is the HandleExternalEventActivity, the event handler can contain any activities. If an activity other than HandleExternalEventActivity is contained in EventDrivenActivity, that activity cannot have an event handler.
For example, an activity that supports event handling can be used inside the EventDrivenActivity but the activity cannot have event handlers attached to itself.
Another example is that the EventDrivenActivity can contain a ConditionedActivityGroup, but the ConditionedActivityGroup itself cannot contain any HandleExternalEventActivity classes.
The following code example shows how to use the EventDrivenActivity to perform state machine transitions. This code example is part of the SimpleStateMachineWorkflow SDK sample from the StateMachineWorkflow.cs file. For more information, see Simple State Machine.
System.Workflow.ComponentModel.DependencyObject
System.Workflow.ComponentModel.Activity
System.Workflow.ComponentModel.CompositeActivity
System.Workflow.Activities.SequenceActivity
System.Workflow.Activities.EventDrivenActivity
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.