询问者
DelayActivity在使用ManualWorkflowSchedulerService调用服务时的问题

问题
-
在顺序工作流中如果存在DelayActivity,如果使用ManualWorkflowSchedulerService调用服务时工作流将无法正常运行。
WorkflowRuntime runtime1 = new WorkflowRuntime();
ManualWorkflowSchedulerService scheduler;
scheduler = new ManualWorkflowSchedulerService();
runtime1.AddService(scheduler);
WorkflowInstance instance;
instance = runtime1.CreateWorkflow(typeof(Workflow1));
Console.WriteLine("Setting up workflow from thread {0}",
Thread.CurrentThread.ManagedThreadId);
instance.Start();
scheduler.RunWorkflow(instance.InstanceId);- 已移动 小鱼儿 2009年5月19日 10:30 ([Loc]From:.NET Framework 相关)
全部回复
-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;namespace TestWorkflow
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Start Manual Service");
WorkflowRuntime runtime1 = new WorkflowRuntime();
ManualWorkflowSchedulerService scheduler;
scheduler = new ManualWorkflowSchedulerService();
runtime1.AddService(scheduler);WorkflowInstance instance1;
instance1 = runtime1.CreateWorkflow(typeof(Workflow1));
Console.WriteLine("Setting up workflow from thread {0}",
Thread.CurrentThread.ManagedThreadId);
instance1.Start();
scheduler.RunWorkflow(instance1.InstanceId);
Console.WriteLine("Manual Service");Console.WriteLine("Start Default Service");
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false);
workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();};
workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(TestWorkflow.Workflow1));
instance.Start();
Console.WriteLine("Default Service");waitHandle.WaitOne();
}Console.ReadLine();
}
}
}======================================================================================
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Reflection;
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.Rules;namespace TestWorkflow
{
partial class Workflow1
{
#region Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.CanModifyActivities = true;
this.codeActivity1 = new System.Workflow.Activities.CodeActivity();
this.delayActivity1 = new System.Workflow.Activities.DelayActivity();
//
// codeActivity1
//
this.codeActivity1.Name = "codeActivity1";
this.codeActivity1.ExecuteCode += new System.EventHandler(this.codeActivity1_ExecuteCode);
//
// delayActivity1
//
this.delayActivity1.Name = "delayActivity1";
this.delayActivity1.TimeoutDuration = System.TimeSpan.Parse("00:01:00");
//
// Workflow1
//
this.Activities.Add(this.delayActivity1);
this.Activities.Add(this.codeActivity1);
this.Name = "Workflow1";
this.CanModifyActivities = false;}
#endregion
private DelayActivity delayActivity1;
private CodeActivity codeActivity1;
}
}========================================================================================
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
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.Rules;
using System.Threading;namespace TestWorkflow
{
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Hello from {0}", this.QualifiedName);
Console.WriteLine(" I am running on thread {0}",
Thread.CurrentThread.ManagedThreadId);
}
}}