- Microsoft Windows Workflow Foundation 4.0 Cookbook
- Andrew Zhu
- 336字
- 2021-04-13 17:00:34
In this task, we will create the same "HelloWorkflow" function workflow using pure C# code, beginning from a Console Application.
- Create a Console Application project:
Create a new Console Application project under the
Chapter01
solution. Name the projectHelloCodeWorkflow
. The following screenshot shows the Console Application new project dialog: - Add reference to the
System.Activities
assembly:By default, a new Console Application doesn't have reference to the
System.Activities
assembly, due to which we need to perform this step. - Create workflow definition code:
Open
Program.cs
file and change the code present as follows:using System.Activities; using System.Activities.Statements; namespace HelloCodeWorkflow { class Program { static void Main(string[] args) { WorkflowInvoker.Invoke(new HelloWorkflow()); } } public class HelloWorkflow:Activity { public HelloWorkflow() { this.Implementation = () => new Sequence { Activities = { new WriteLine(){Text="Hello Workflow"} } }; } } }
- Run it:
Set
HelloCodeWorkflow
asStartUp
project and press Ctrl+F5 to run it. As expected, the result should be just like the previous result shown.
We use the following namespaces:
using System.Activities; using System.Activities.Statements;
Because WorflowInvoker
class belongs to System.Activities
namespace. Sequence
activity, WriteLine
activity belongs to System.Activities.Statements
. namespace.
public class HelloWorkflow:Activity { public HelloWorkflow() { this.Implementation = () => new Sequence { Activities = { new WriteLine(){Text="Hellow Workflow"} } }; } }
By implementing a class inherited from Activity, we define a workflow using imperative code.
WorkflowInvoker.Invoke(s);
This code statement loads a workflow instance up and runs it automatically. The WorkflowInvoker.Invoke
method is synchronous and invokes the workflow on the same thread as the caller.
- Instant Vert.x
- Word論文排版之道
- Moodle 2 for Teaching 4/9 Year Olds Beginner's Guide
- Photoshop CS6 互聯(lián)網(wǎng)應(yīng)用設(shè)計(jì)教程
- OpenStack實(shí)戰(zhàn)指南
- ADOBE FLASH PROFESSIONAL CS6 標(biāo)準(zhǔn)培訓(xùn)教材
- 新編 中文版Photoshop入門(mén)與提高
- TopSolid Wood軟件設(shè)計(jì)技術(shù)與應(yīng)用
- CAD/CAE技術(shù)應(yīng)用
- Photoshop CC中文版基礎(chǔ)教程
- 老郵差 Photoshop數(shù)碼照片處理技法 圖層篇(修訂版)
- AutoCAD 2020中文版從入門(mén)到精通(升級(jí)版)
- 電磁場(chǎng)數(shù)值計(jì)算及基于FreeFEM的編程實(shí)現(xiàn)
- Moodle 1.9 Math
- Photoshop 圖形圖像處理