WindowsWorkFlow第一个小程序

       看到网上普遍流传的一个WWF的入门示例(HelloWorld),个人感觉它只是让初学者在VS2005中跑起了一个WWF的小程序,但却没有让读者感受到Workflow的一丁点含义,我的这个入门示例是跟WorkFlow打招呼:

打招呼的两种形式(也可以说是流程吧,呵呵)

       Hello Workflow

       Workflow Hello

两种不同的打招乎的流程(仅公假设而已)

确保你机子上装了

 

VS2005

DOTNET3.0

Visual Studio 2005 Extensions for Windows Workflow Foundation (CHS)

打开VS2005,新建一个项目,选择Visual C#(当然也可以先VB)节点,再点击workflow,选择顺序工作流控制台应用程序,OK这样一个项目就建立好了.

 

双击workflow1.cs转到设计视图,从工具箱中分别将两个code activity拖到顺序工作流中,如下图所示:

Code表示执行的代码块,看到每个activity右上方都有代码块了吗?是因为我们还没有为它指定代码块,别急,我们这就来搞定它!

 

双击第一个codeActivity,自动转到代码中(这与我们在VB中的感觉一样吧),在光标处写上代码:

       Console.Write("Hello ");

同样双击每二个codeActivity,写上代码:

       Console.Write("Workflow ");

为了我们在运行程序时可以看到效果,打开Program.csMain方法块内,结尾加上

     Console.ReadLine();

F5,运行后如图:

    

问题又来了,当我们要表达Workflow Hello,该怎么办,改动方法体内部的代码,

codeActivity1_ExecuteCode方法中

Console.Write("Hello ");换成Console.Write("Workflow ");

codeActivity2_ExecuteCode方法中

Console.Write("Workflow ");换成Console.Write("Hello ");

其实完全不用这样:

    

选中codeActivity1,在属性窗口中将ExecuteCode属性值选为codeActivity2_ExecuteCode

(在下拉列表中选取即可)

同样将codeActivity2ExecuteCode属性值选为codeActivity1_ExecuteCode

OK,F5,是不是出现了 Workflow Hello.

从" Hello Workflow"到" Workflow Hello"的转变,只须轻点几下 

希望这是一个好的开始.

 
英文版 Windows Workflow Foundation (WF) is a revolutionary part of the .NET 4 Framework that allows you to orchestrate human and system interactions as a series of workflows that can be easily mapped, analyzed, adjusted, and implemented. As business problems become more complex, the need for workflow-based solutions has never been more evident. WF provides a simple and consistent way to model and implement complex problems. As a developer, you focus on developing the business logic for individual workflow tasks. The runtime handles the execution of those tasks after they have been composed into a workflow. Pro WF: Windows Workflow in .NET 4 provides you with the skills you need to incorporate WF in your applications, using a lively tutorial style with each example illustrated in C#. This book gets you up to speed with WF 4 quickly and comprehensively. Learn about WF 4s new designer, its updated programming paradigm, and the completely new set of activities that can enable and extend your workflows. This book also includes detailed coverage of how to customize your workflows and access them in a variety of ways and situations so you can maximize the advantages of this technology. What youll learn * WF 4 basics * New activities and changes to existing activities in WF 4 * Customizing your workflows * Accessing your workflows in a variety of ways in a variety of situations * Using WF with Web Services and ASP.NET * Integrating WCF and WF Who this book is for This book is for intermediate to advanced .NET developers who need to learn how to use the latest version of Windows Workflow Foundation (WF 4). This book is not a primer on .NET or the C# language. To get the most out of the examples presented in this book, it is necessary to have a good working knowledge of .NET 2.0 or higher. All of the examples are presented in C#. Table of Contents * A Quick Tour of Windows Workflow Foundation * Foundation Overview * Activities * Workflow Hosting * Procedural Flow Control * Collection-Related Activities * Flowchart Modeling Style * Host Communication * Workflow Services * Workflow Services Advanced Topics * Workflow Persistence * Customizing Workflow Persistence * Transactions, Compensation, and Exception Handling * Workflow Tracking * Enhancing the Design Experience * Advanced Custom Activities * Hosting the Workflow Designer * WF 3.x Interop and Migration
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值