Exercise 1: Hello Workflow
Workflows execute a business process. Each step in that process is implemented by an Activity.
In this exercise, you will create and test a simple “Hello World” process using Windows Workflow Foundation 4.
Task 1 – Creating a Simple Hello Workflow Application
In this task you will create a very simple workflow that will be the equivalent to this code:
private static void SayHello()
{
Console.WriteLine("Hello Workflow 4");
}
Private Shared Sub SayHello()
Console.WriteLine("Hello Workflow 4")
End Sub
- Start Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010.
- Select File / New Project Ctrl+Shift+N and set the project options
- Installed Templates: select either Visual C# or Visual Basic then select Workflow under the language
- Template: Workflow Console Application
- Name: HelloWorkflow.
- Location: %TrainingKitInstallFolder%\Labs\IntroToWF\Ex1-HelloWorkflow\Begin
- Solution: HelloWorkflow
.png)
Figure 1Creating a new Workflow Console Application (C#)
.png)
Figure 2Creating a new Workflow Console Application (Visual Basic)
- Since your business process is a 1-step process, you can simply add a WriteLine activity to implement the process. From the Toolbox, drag a WriteLine activity and drop it on the design surface.
.png)
Figure 3Adding a WriteLine activity
If the Toolbox window is not visible, select Toolbox from the View menu.
- Set the WriteLineText property to "Hello Workflow 4".
.png)
Figure 4Setting the Text property
WriteLine ActivityThe
WriteLine activity is a simple activity that will display a message on the console. The text property is an
Expressionwhich could be the result of calling a function or evaluating the property of an object. In this case, the expression is a literal string so you must quote the string.
Next Step
Exercise 1 Verification