Beginning wf4-Chapter 1 01 create a simple Workflow

Source: Internet
Author: User

Before creating a simple workflow example, open vs2010 and run the "file. new. project, and select the "workflow" node. Here we will find four templates.

In the "name" column, enter chapter01, select the "workflow console application" template, and click OK.

 

(Figure 1-1)

 

WF"Hello world !"

In this case, the template will automatically generate a framework with simple workflow functions, as shown in vs2010 IDE.

 

(Figure 1-2)

 

We can simply divide the development platform into three work areas: 1 as the workflow flow design area, 2 as the variable and parameter design area, and 3 as the workflow toolbox.

In area 2, you can click "variable", "parameter", or "import" multiple times to enable or disable it. The "variables" are designed as follows:

 

(Figure 1-3)

"Parameters" include:

 

(Figure 1-4)

If we take the "activity" ratio in the workflow as a class, the "variables" and "Parameters" are similar to the "variables" and "Parameters" in the method ". It is particularly worth noting that the parameter in the activity needs to specify its "visible field ".

 

 

Design Workflow

In Area 1 in Figure 1-2, we will find that the initial workflow is empty. If we want a workflow to output "Hello World !", Follow these steps:

Drag a "sequence" from the control flow of the toolbox to Area 1, and then drag a "writeline" from the Toolbox base to the newly added "sequence, the final effect is as follows:

 

(Figure 1-5)

In the selected "writeline", the base attributes are as follows:

 

(Figure 1-6)

In this case, you only need to enter(Note: The quotation marks are in English):

"Hello world! "

 

At the same time, change the code in prsag. CS to the following:

 

using System;using System.Linq;using System.Activities;using System.Activities.Statements;namespace Chapter01{    class Program    {        static void Main(string[] args)        {            WorkflowInvoker.Invoke(new Workflow1());            Console.WriteLine("Press ENTER to exit");            Console.ReadLine();        }    }}

 

 

The following two lines of code are added:

Console. writeline ("press enter to exit ");

Console. Readline ();

 

(Note: These two lines of code are mainly used to view the results during running. If not, the code will flash off after running)

 

Press F5 to run:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.