WF4.0 Basic article (i) Start using wf--Next Chapter

Source: Internet
Author: User

Create a WF4.0 Project

1. Open VS2010, [File], [New], [Project]

2. In the [installed Templates] Tree of the [New Project] dialog box that appears [Workflow], select the [Workflow Console application] Item in the Template list box that appears

Enter [Helloworkflow] in the [Name] box and click [OK] to enter the design interface of the WF4.0 project.

Create a workflow for the output of a "Hello wxwinter" screen

Press [F5] to run the process, you will see the following results

Program Structure Description

This example includes two parts, a XAML file that describes the process structure, and a host program that invokes the process

XAML Process Structure Description file

The WF4.0 process structure description file is an XML-formatted file with the following format

(the XAML file format for WF4.0, which is described in a later article, is a basic explanation here)

<activity

X:class= "Helloworkflow.workflow1"

....

>

<writeline

text= "Hello Wxwinter"

....

/>

</Activity>

WF4.0 processes are made up of a set of [activities], and when the process runs, the [activity] in the process executes according to certain rules

Where <Activity> </Activity> is the root of the process [activity]

<writeline/> is a self-bringing [activity] of WF4.0, whose function is to print the contents of the [Text property] on the screen

X:class= "Helloworkflow.workflow1" is the class name that corresponds to compiling the xoml file into a net class

Host Program

When created using the [Workflow Console application] template, a console host program for the test process is automatically created, as follows

Class Program

{

static void Main (string[] args)

{

Workflowinvoker.invoke (New Workflow1 ());

}

}

where [Workflowinvoker] is a function class for invoking a workflow, you can invoke the process using the Invoke static method of the class. In this case [Invoke (New Workflow1 ())] The class used is the xoml file x:class= " Helloworkflow.workflow1 "The class name defined by

Code mode create WF4.0 workflow

Class Program

{

static void Main (string[] args)

{

Workflowinvoker.invoke (Codecreateworkflow ());

}

Code mode create WF4.0 workflow

Static Activity Codecreateworkflow ()

{

WriteLine writelineactivity = new WriteLine () {Text = "Hello Wxwinter"};

Sequence Wxwinterworkflow = new Sequence ();

WXWINTERWORKFLOW.ACTIVITIES.ADD (writelineactivity);

return wxwinterworkflow;

}

}

Press [F5] to run the process, you will see the following results

WF4.0 Basic article (i) Start using wf--Next Chapter

Related Article

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.