您的位置:首页 > 其它

我的Windows Workflow Foundation 之旅---(5)工作流通信例子

2008-11-09 11:31 441 查看
[上一节]

本节我们做一个工作流通信的简单例子,具体的概念请参考上一节的内容。

一. 通信服务:

新建一个“顺序工作流控制台应用程序”,然后右键解决方案→添加→新建项目→类库。如图:

Code

1 static void Main(string[] args)

2 {

3 using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())

4 {

5 AutoResetEvent waitHandle = new AutoResetEvent(false);

6 ExternalDataExchangeService dataService = new ExternalDataExchangeService();

7 workflowRuntime.AddService(dataService);

8 dataService.AddService( new MessageService());

9 workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();};

10 workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)

11 {

12 Console.WriteLine(e.Exception.Message);

13 waitHandle.Set();

14 };

15

16 Dictionary<string, object> parms = new Dictionary<string, object>();

17 parms.Add("消息","我叫无忧,大家早上好");

18

19 WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Demo1.Workflow1),parms);

20 instance.Start();

21

22 waitHandle.WaitOne();

23 }

24 }

运行结果如图:



[源代码]

[下一节]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐