Compartilhar via


Replicator Sample

Download sample

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:

Output from Replicator sample

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

See Also

Reference

ReplicatorActivity
Initialized

Other Resources

Using the Replicator Activity
Activities Samples
Windows Workflow Foundation Samples

© 2007 Microsoft Corporation. All rights reserved.