手動調度服務_第1頁
手動調度服務_第2頁
手動調度服務_第3頁
手動調度服務_第4頁
手動調度服務_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、1 ManualWorkflowSchedulerService 手動調度服務當該服務加載到引擎中后,有如下特點:1. 如果實例正在運行,宿主的當前進程將被阻塞,直到工作流實例進入idle狀態(tài),引擎對宿主的阻塞才結束2. 對實例的操作,如啟動(Start)、觸發(fā)外部事件(handleExternalEventActivity)等操作,只以手動調用ManualWorkflowSchedulerService 服務的RunWorkflow(實例ID)方法,才會真正執(zhí)行3. 只有調用ManualWorkflowSchedulerService 服務的RunWorkflow(實例ID)方法時,流程才運

2、行,宿主才被阻塞4. 當實例進入idle狀態(tài)時組塞才結束5. 可以依次調用完所用的觸發(fā)外部事件(handleExternalEventActivity),再調用ManualWorkflowSchedulerService 服務的RunWorkflow(實例ID)方法開始執(zhí)行ManualWorkflowSchedulerService mws;WorkflowRuntime runtime;runtime = newWorkflowRuntime();mws = newManualWorkflowSchedulerService();runtime.AddService(mws);Workflo

3、wInstance instance = runtime.CreateWorkflow(typeof(Workflow1);Guid instanceId;instanceId = instance.InstanceId;instance.Start(); /此時,實例并沒開始mws.RunWorkflow(instanceId);/實例開始2 與正常的工作流對比說明2.1 外部事件using System;using System.Collections.Generic;using System.Text;using System.Workflow.Activities;namespace

4、ExternalDataExchangepublicinterfaceIEXService eventEventHandler<ExtEventArgs> one;eventEventHandler<ExtEventArgs> tow;eventEventHandler<ExtEventArgs> three; SerializablepublicclassExService : IEXService publiceventEventHandler<ExtEventArgs> one;publiceventEventHandler<ExtE

5、ventArgs> tow;publiceventEventHandler<ExtEventArgs> three;publicvoid Rone(Guid instanceId) if (this.one != null) this.one(this, newExtEventArgs(instanceId); publicvoid Rtow(Guid instanceId) if (this.tow != null) this.tow(this, newExtEventArgs(instanceId); publicvoid Rthree(Guid instanceId)

6、if (this.three != null) this.three(this, newExtEventArgs(instanceId); SerializablepublicclassExtEventArgs : ExternalDataEventArgs public ExtEventArgs(Guid instanceId) : base(instanceId) 2.2 工作流2.3 工作流結點代碼using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Collect

7、ions;using System.Drawing;using System.Workflow.ComponentModel.Compiler;using System.Workflow.ComponentModel.Serialization;using System.Workflow.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Workflow.Runtime;using System.Workflow.Activities;using System.Workflow.Activities.

8、Rules;namespacepublicsealedpartialclassWorkflow1: SequentialWorkflowActivitypublic Workflow1()InitializeComponent();privatevoid codeActivity1_ExecuteCode(object sender, EventArgs e) System.Console.WriteLine("開始" + DateTime.Now.ToString(); privatevoid codeActivity2_ExecuteCode(object sender

9、, EventArgs e) System.Console.WriteLine("One(隨后sleep 20M)" + DateTime.Now.ToString(); System.Threading.Thread.Sleep(20000); privatevoid codeActivity3_ExecuteCode(object sender, EventArgs e) System.Console.WriteLine("two" + DateTime.Now.ToString(); privatevoid codeActivity4_Execut

10、eCode(object sender, EventArgs e) System.Console.WriteLine("three" + DateTime.Now.ToString(); 2.4 宿主代碼Guid instanceId;WorkflowRuntime runtime;ExService exchangeServer;ManualWorkflowSchedulerService mws;/正常啟動引擎privatevoid button1_Click(object sender, EventArgs e) runtime = newWorkflowRuntim

11、e();ExternalDataExchangeService exchange = newExternalDataExchangeService(); runtime.AddService(exchange); exchangeServer = newExService(); exchange.AddService(exchangeServer); runtime.StartRuntime();WorkflowInstance instance = runtime.CreateWorkflow(typeof(Workflow1); instanceId = instance.Instance

12、Id; instance.Start(); /ManualWorkflowSchedulerService方式啟動引擎privatevoid button5_Click(object sender, EventArgs e) runtime = newWorkflowRuntime();ExternalDataExchangeService exchange = newExternalDataExchangeService(); runtime.AddService(exchange); mws = newManualWorkflowSchedulerService(); runtime.Ad

13、dService(mws); exchangeServer = newExService(); exchange.AddService(exchangeServer); runtime.StartRuntime();WorkflowInstance instance = runtime.CreateWorkflow(typeof(Workflow1); instanceId = instance.InstanceId; instance.Start(); /oneprivatevoid button2_Click(object sender, EventArgs e) exchangeServ

14、er.Rone(instanceId); /towprivatevoid button3_Click(object sender, EventArgs e) exchangeServer.Rtow(instanceId); /threeprivatevoid button4_Click(object sender, EventArgs e) exchangeServer.Rthree(instanceId); /ManualWorkflowSchedulerService的RunWorkflowprivatevoid button6_Click(object sender, EventArgs

15、 e) mws.RunWorkflow(instanceId); 2.5 正常使用開始-09-12 14:33:35One(隨后sleep 20M)2007-09-12 14:33:38two2007-09-12 14:34:05three2007-09-12 14:34:141. 啟動,開運行 codeActivity1的代碼,顯示"開始-09-12 14:33:35",然后進入one的idel2. 觸發(fā)one,并運行codeActivity2的代碼,,顯示"One(隨后sleep 20M)2007-09-12 14:33:38",Sleep 20秒后

16、,進入two的idel3. 觸發(fā)two,并運行codeActivity3的代碼,,顯示"two2007-09-12 14:34:05",進入three的idel4. 觸發(fā)three,并運行codeActivity4的代碼,,顯示"three2007-09-12 14:34:14",進入three的idel注意:A. 當執(zhí)行codeActivity2的Sleep 20秒的過程中, 宿主線程并沒有被阻塞??梢岳^承點擊其他按鈕B. 可以不等codeActivity2的Sleep 20秒的過程結束,就可以直接點擊后面的按鈕,觸發(fā)tow與three,此時,這些執(zhí)行

17、將在實例里排隊,最后都會被依次執(zhí)行開始-09-12 14:39:22線程0x954 已退出,返回值為0 (0x0)。線程0x1b0 已退出,返回值為0 (0x0)。two2007-09-12 14:39:42three2007-09-12 14:39:42由于是排隊,codeActivity3與codeActivity4,的執(zhí)行,幾乎沒有時間差2.6 使用ManualWorkflowSchedulerService開始2007-09-12 14:43:13One(隨后 sleep 20M)2007-09-12 14:43:13two2007-09-12 14:43:38three2007-09-12 14:43:40操作過程是1,run (啟動 -> codeActivity1 -> one idel)2,run (觸發(fā)one ->codeActivity2 -> two idel)3,run (觸發(fā)two -> codeActivity3 -> three idel)4,run (觸發(fā)three -> codeActivity4 -> 完成)當實例沒有進入idel時,宿組線程是被阻塞的,這時無法操作任何按鈕,程序也進入一種無響應狀態(tài)注意:A. 對實例的所有操作只有執(zhí)行ManualWorkflowSch

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論