Basic Activity Composition

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

This sample demonstrates how to compose custom activities and system-provided activities to build more custom activities.

The workflow using the Survey activity schedules the Survey with a list of questions, and then outputs the responses received.

Sample Details

This sample uses three custom activities. ReadLine is a simple NativeActivity<string> that creates a Bookmark when scheduled, and then sets the Return OutArgument to the value with which the Bookmark is resumed. Prompt is an Activity<string> that takes an InArgument<string> named Text and returns the users response in the Result OutArgument<string>. The Prompt activity uses the Sequence and WriteLine activities that ship as part of the .NET Framework, and also incorporates the custom ReadLine activity for getting user input. The last custom activity is the Survey activity. It is an Activity<ICollection<string>>. This activity takes an InArgument<IEnumerable<string>> named Questions and populates the Result out argument with the responses. The Survey activity uses ForEach, Sequence and AddToCollection from the .NET Framework and employs the Prompt activity for asking the survey questions and getting responses.

To set up, build, and run the sample

  1. Open the BasicActivityComposition.sln sample solution in Visual Studio 2010.

  2. Build and run the solution.

Dd759028.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\CustomActivities\Composite\ActivityComposition