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:

C#

private static void SayHello() { Console.WriteLine("Hello Workflow 4"); }

Visual Basic

Private Shared Sub SayHello() Console.WriteLine("Hello Workflow 4") End Sub

  1. Start Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010.
  2. Select File / New Project Ctrl+Shift+N and set the project options

    1. Installed Templates: select either Visual C# or Visual Basic then select Workflow under the language
    2. Template: Workflow Console Application
    3. Name: HelloWorkflow.
    4. Location: %TrainingKitInstallFolder%\Labs\IntroToWF\Ex1-HelloWorkflow\Begin
    5. Solution: HelloWorkflow

    Figure 1

    Creating a new Workflow Console Application (C#)

    Figure 2

    Creating a new Workflow Console Application (Visual Basic)

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

    Figure 3

    Adding a WriteLine activity

    Note:
    If the Toolbox window is not visible, select Toolbox from the View menu.

  4. Set the WriteLineText property to "Hello Workflow 4".

    Figure 4

    Setting the Text property

    Note:
    WriteLine Activity

    The 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