Hello World Custom Activity
This sample demonstrates several key features of Windows Workflow Foundation (WF), including how to create a simple custom activity. Some of the features demonstrated in this sample are creating a custom activity in C# and using in and out arguments (InArgument and OutArgument).
The samples may already be installed on your computer. Check for the following (default) directory before continuing.
Creating a Workflow in Code
In this sample, two custom activities are created using C# code. Both custom activities inherit directly or indirectly from Activity to return a single value. The advantage of using the generic return value, instead of inheriting from the non-generic Activity class, is that some activities (such as Assign) are able to access the return value when used as part of a composed activity.
- This activity inherits from Activity, and uses an Assign activity that concatenates two strings together.
- Prepend String
This activity inherits directly from CodeActivity, and creates similar functionality to the
AppendStringactivity, which uses logic implemented in code rather than being composed of a pre-existing activity.
The following files are included in this project.
- The custom activity that appends strings together. It takes in a string and combines it with a literal text string “ says hello world” to form a complete message as output.
- This activity prefixes a predefined string to an input string.
A workflow that uses the
- A program that runs the workflow.
To use this sample
Using Visual Studio 2010, open the HelloWorld.sln solution file.
To build the solution, press CTRL+SHIFT+B.
To run the solution, press F5.