This sample demonstrates a simple use of the ReplicatorActivity activity. The ReplicatorActivity activity can create and execute an arbitrary number of identical child activities either sequentially or in parallel.
The sample creates a simple custom activity, SampleReplicatorChildActivity. Nothing is replicator-specific about this activity; it just has a Name property and a CodeHandler method that writes the Name value to the console. The workflow consists of a ReplicatorActivity activity that contains the SampleReplicatorChildActivity.
To configure the ReplicatorActivity activity, the InitialChildData property is bound to an IEnumerable property of the workflow (in this case, the ChildData property). Additionally, a handler is created for the ChildInitialized event. This handler passes the data from the item in this collection to the actual instance of the child being initialized. In this case, the string value from the collection is set on the Name property of the ReplicatorChildActivity instance.
Running the sample causes two instances of the ReplicatorChildActivity to be created and executed. This gives you the following console output:
To build the sample
Download the sample by clicking Download Sample in this topic.
This extracts the sample project to your local hard disk.
Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.
Go to the source directory of the sample.
At the command prompt, type MSBUILD <Solution file name>.
To run the sample
In the SDK Command Prompt window, run the .exe file in the SimpleReplicator\bin\debug folder (or the SimpleReplicator\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample..
© 2007 Microsoft Corporation. All rights reserved.