Поделиться через


Using the ConditionedActivityGroup Activity

The ConditionedActivityGroup activity contains a collection of child activities whose execution order is controlled by conditions applied to these child activities. For more information about conditions, see Using Conditions in Workflows.

The ConditionedActivityGroup activity condition-driven execution logic provides many ways to order the execution of the child activities, including a type of parallel activity execution similar to the ParallelActivity activity, and a looping type of behavior. For example, you can use a ConditionedActivityGroup activity to loop through a set of activities conditionally, based on criteria specific to each activity, until an Until condition is true for the ConditionedActivityGroup as a whole.

You apply an Until condition to the ConditionedActivityGroup activity using UntilConditionProperty. You can separately apply a When condition, by using WhenConditionProperty, to each first descendant child activity in the ConditionedActivityGroup. If you do not specify an Until condition, the ConditionedActivityGroup activity finishes when no child activities are executing, and the When condition for each ConditionedActivityGroup first descendant child activity evaluates to false. If you do not specify a When condition on an activity, the activity executes only one time.

When a ConditionedActivityGroup activity first starts executing, it evaluates its Until condition. If the Until condition evaluates to false, the When condition of all the first descendant child activities that are contained in the ConditionedActivityGroup activity are evaluated. If an activity's When condition evaluates to true, it is scheduled for execution. This Until and When condition evaluation is repeated every time that a first descendant child activity is completed.

Every time an executing child activity completes execution, the Until condition for a ConditionedActivityGroup activity and the When conditions for all the first descendant child activities that are not executing are reevaluated. Therefore, the other first descendant child activities can be newly scheduled or rescheduled for execution depending on what occurred in the just-completed activity. As soon as the Until condition on the ConditionedActivityGroup activity evaluates to true, it immediately cancels any currently executing child activities.

When a child activity is executed more than once, a separate instance of the activity is created for each iteration. This enables the instances to execute independently (and potentially in parallel, as in the case of a ReplicatorActivity activity). As a consequence, the definition of the activity in the activity tree (referred to as the template) is never executed and will always be in the Initialized state. Access to the running instances of the template is provided by the composite activity that is the parent of the template. For example, in the case of the ConditionedActivityGroup activity, there is always one active instance and the GetDynamicActivity returns this instance.

For more information, see the ConditionedActivityGroup class of the System.Workflow.Activities namespace in the Windows Workflow Foundation Class Library reference.

For a code sample that demonstrates how to use the ConditionedActivityGroup activity, see Using the ConditionedActivityGroup.

See Also

Reference

ConditionedActivityGroup
UntilConditionProperty
WhenConditionProperty

Concepts

Using Conditions in Workflows
Using the ParallelActivity Activity
How to: Use Conditions Through Code
Rules and Conditions Overview

Other Resources

Rules and Conditions Samples
Using ConditionedActivityGroup Sample
Windows Workflow Foundation Activities