Compartilhar via


ConditionedActivityGroup Sample

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. Download the sample by clicking Download Sample in this topic. This extracts the sample project to your local hard disk.

  2. Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.

  3. Go to the source directory of the sample.

  4. At the command prompt, type MSBUILD <Solution file name>.

To run the sample

  1. 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..

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

© 2007 Microsoft Corporation. All rights reserved.