O'Reilly logo

Microsoft Windows Workflow Foundation 4.0 Cookbook by Andrew Zhu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Variable in a WF program

We can use Variable temporarily to store a value when a WF program is running. In this task, we will create a WF program that prints five numbers to the console in a loop. We will use the NumberCounter variable as a number counter.

How to do it...

  1. Create a workflow project:

    Create a new Workflow Console Application under the Chapter01 solution and name the project as UseVariable.

  2. Author a workflow:

    Add a Sequence activity, click the Sequence activity, create an Int32 NumberCounter variable, and set its Scope to Sequence. Then, author the workflow as shown in the following screenshot. In the second Assign activity type NumberCounter=NumberCounter+1.

  3. Run it:

    Set UseVariable as Startup project. Press Ctrl+F5 to build and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required