Event Driven Activity
Last changed:

Wraps an Activity whose execution is initialized by an event.

It is a CompositeActivity that is used to handle an event; typically it can be raised from the host or by the run time in reponse 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, meaning 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 StateMachineWorkflow contains an EventDrivenActvity, the EventDrivenActivity has some restrictions. The EventDrivenActivity may contain one, and only one, activity of type IEventActivity, and 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.

See also: CreatingATimeoutOnAnActivity