[WWF] opening

Source: Internet
Author: User

WWFIntroduction

Download

Windows Workflow Foundation (WWF) is a programming model, engine, and tool used to quickly generate an application to start a workflow on Windows. it includes a namespace, an in-process workflow engine, and multiple Visual Studio 2005 designers. Windows Workflow Foundation is a framework that allows you to create system or manual workflows in applications written for Windows Vista, Windows XP, and Windows Server 2003.

Windows Workflow Foundation can handle the following solutions:

L enable workflow in business line applications

L stream on the user interface page

L document-centric Workflow

L manual Workflow

L composite workflow for service applications

L business rule-driven Workflow

L system management workflow

The first simple WWF program

After introducing what WWF is and what it can do. Let's start to create a simple WWF program to briefly describe how to create the WWF application.

Step 1: Create a workflow project

Open Visual Studio 2008 and create a project. The Create Project dialog box appears, 1-1-1.

Figure 1-1-1

In the "project type" area on the left, select workflow. The "template" area on the right shows the workflow project template that can be created. Here, select "Empty workflow project ". Enter a name, select a location, and click OK. The workflow project is successfully created.

Step 2: Add a sequence Workflow

On the 1-1firstworkflowapplication project, right-click a [add] a sequence workflow. The add new project dialog box is displayed. Enter a name and click [add.

Figure 1-1-2

2 files will be added to the project, 1-1-3.

Figure 1-1-3

Step 3: Add code activity to the ordered Workflow

Double-click "hellowworld. CS file to go to the design view interface of the ordered workflow. find the "code" icon in the toolbox and drag it to the design view of the workflow, 1-1-4.

Figure 1-1-4

Step 4: add the Execution Code for the code Activity

Click the code activity symbol added to the workflow, and click [executecode with no attribute set] to turn to properties. At the executecode attribute, enter sayhello. move the cursor away and add the sayhello function to the background code of the workflow file. 1-1-5 and Fig 1-1-6.

Figure 1-1-5

Figure 1-1-6

Step 5: write code for the sayhello function.

Private void sayhello (Object sender, eventargs E)

{

Console. Write ("Hello world \ r \ n ");

}

Step 6: Create a workflow project Step 7: Create a console project to run the workflow.

Right-click solution à New à project, and the Add new project dialog box is displayed, ranging from 1 to 7.

Figure 1-1-7

Select console application template à OK.

Step 8: Add a reference for the console Project

System. workflow. Runtime

System. workflow. Activities

System. workflow. componentmodel

Add namespace for program. CS

Using system. workflow. runtime;

Using system. workflow. runtime. Hosting;

Step 9: Create workflowruntime

Using (workflowruntime = new workflowruntime ())

{

}

Step 10: Process workflowruntime events

Workflowruntime. Started + = delegate (Object sender, workflowruntimeeventargs E)

{

Console. Write ("workflowruntime started \ r \ n ");

};

Step 2: run the Workflow

Using system. Threading;

Declare thread asynchronous variables:

Autoresetevent waithandle = new autoresetevent (false );

Register the workflowcompleted event:

Workflowruntime. workflowcompleted + = delegate (Object sender, workflowcompletedeventargs E)

{

Waithandle. Set ();

Console. Write ("workflow completed \ r \ n ");

};

Create a workflow instance:

Workflowinstance workflow = workflowruntime. createworkflow (typeof (_ 1_1firstworkflowapplication.helloworld ));

Workflow. Start ();

Waithandle. waitone ();

Step 2: compile and generate the app to run the Console

Running result 1-1-8

Figure 1-1-8

Conclusion

Review the first workflow project to learn about how to create a workflow project and how to call a workflow in an application. A sequential workflow is created in the workflow project to add a codeacitiworkflow activity to the workflow. added the sayhello Execution Code for the codeacitivity activity. in the console project, use workflowruntime to create a workflow instance and execute the workflow. add an event handler for workflowruntime to monitor workflow execution.

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.