Conditioned Activity Group

This topic applies to Windows Workflow Foundation 4 (WF4).

The sample demonstrates a travel booking application. The ConditionedActivityGroup (CAG) has two code activities: a Car activity and an Airline activity. In the SimpleCAGWorkflow constructor, a "travelNeedType" ArrayList object is populated with the types of travel bookings that are required. By commenting out one or both of the travelNeeds.Add statements, you modify the CAG behavior accordingly. Both the Car and Airline activities have their WhenConditionProperty condition populated with a CodeCondition. The Car activity executes only if the travelNeeds collection has a TravelNeeds.Car entry, and the Airline activity executes only if the travelNeeds collection has a TravelNeeds.Airline entry.

The execution of each activity removes the corresponding entry from the collection. The default UntilCondition condition specifies that the CAG should exit when no children are executing or are ready for execution (based on their WhenConditionProperty conditions). In this sample, this means that the CAG exits when the travelNeeds collection is empty.

To build the sample

  1. Open the solution in Visual Studio 2010.

  2. Build the solution by pressing CTRL+SHIFT+B.

  3. Run the solution without debugging by pressing CTRL+F5.

To run the sample

  • In the SDK Command Prompt window, run the .exe file in the SimpleCAG\bin\debug folder (or the SimpleCAG\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.
Ee960226.Important(en-us,VS.100).gif Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing:

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory:

<InstallDrive>:\WF_WCF_Samples\WF\Basic\Rules\SimpleCAG

See Also

Reference

ConditionedActivityGroup
WhenConditionProperty
CodeCondition
UntilCondition

Other Resources

Using the ConditionedActivityGroup
Using Activities to Control Flow
Using Conditions in Workflows
Using Conditions through Code
Tutorial: Use Rules and Conditions
Rules and Conditions Overview
Activities Samples
Windows Workflow Foundation Samples