WorkflowApplication输出

时间:2011-07-07 17:41:23

标签: c#-4.0 workflow-foundation workflow-foundation-4

为了从Workflowinvoker获取输出,我们必须使用

          var output = WorkflowInvoker.Invoke(new Activity1() { str = night  });
          HttpContext.Current.Response.Write(output["res"]);

但是我们必须为WorkflowApplication命令使用什么?我尝试过和Workflowinvoker一样,但它不起作用。

1 个答案:

答案 0 :(得分:0)

您需要设置Completed回调。 WorkflowApplication异步执行工作流,而WorkflowInvoker阻塞直到它完成。

var flag = new ManualResetEvent(); 
var app = new WorkflowApplication(activity);
Dictionary<string,object> results = null;
app.Completed = x =>
{
    results = x.Outputs;
    flag.Set();
};
app.Run();
// run the application, wait for it to complete
flag.WaitOne(Timeout.Infinite);
// Completed has executed at this point