异步调用子工作流程活动 [英] Invoke Child Workflow Activity Asynchronously

查看:199
本文介绍了异步调用子工作流程活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

团队:

我需要从WF服务(XAMLX)异步调用WF活动(XAML).我已经在引用Microsoft.Activities.Extensions框架,并且正在状态机的平台更新1上运行-因此,如果解决方案已经在这些库之一中,我就准备好了!

I need to invoke a WF activity (XAML) from a WF service (XAMLX) asynchronously. I am already referencing the Microsoft.Activities.Extensions framework and I'm running on the Platform Update 1 for the state machine -- so if the solution is already in one of those libraries I'm ready!

现在,我需要异步调用该活动(XAML),但是它具有需要在服务(XAMLX)中设置变量的输出参数.有人可以为我提供解决方案吗?

Now, I need to invoke that activity (XAML) asynchronously -- but it has an output parameter that needs to set a variable in the service (XAMLX). Can somebody please provide me a solution to this?

谢谢!

*更新*

现在,我可以发布图片了, *我认为* ,因为我有足够的声誉!让我在这里摆出一对夫妻,尝试更好地解释我的问题.第一张图是WF服务,它具有工作流的两个入口点-第二张图是工作流本身.

Now I can post pictures, * I think *, because I have enough reputation! Let me put a couple out here and try to better explain my problem. The first picture is the WF Service that has the two entry points for the workflow -- the second is the workflow itself.

此工作流程是一种编排机制,该机制会不断自我重启,并具有一些故障转移机制(例如,在错误阈值时退出和软退出),以便我们可以使用WF管理持久性事务队列!

This workflow is an orchestration mechanism that constantly restarts itself, and has some failover mechanisms (e.g. exit on error threshold and soft exit) so that we can manage our queue of durable transactions using WF!

现在,当所有WF服务都使用时,我们的工作流程就可以很好地工作,因为我们可以调用该服务,获取响应并将该响应的值发送回触发器中的另一个入口点,以发出软出口.但是,出现了一项新要求,要求我们使工作流本身成为另一个项目中的WF活动,并在WF Service Application项目中具有接收/发送-答复"序列.

Now, we had this workflow working great when it was all one WF Service because we could call the service, get a response back and send the value of that response back into another entry point in a trigger to issue a soft exit. However, a new requirement has arrisen asking us to make the workflow itself a WF activity in another project and have the Receive/Send-Reply sequences in the WF Service Application project.

但是,我们需要能够启动此工作流程并忽略它-然后让它知道以后需要软退出-但由于WF在单个线程上执行,因此这已经成为一个难题.充满挑战性.

However, we need to be able to startup this workflow and forget about it -- then let it know somehow that a soft exit is necessary later on down the road -- but since WF executes on a single thread this has become a bit challenging at best.

推荐答案

严格地说,在XAML活动中,Parallel和ParallelForEach是执行异步的方式.

Strictly speaking in XAML activities Parallel and ParallelForEach are how you perform asynchrony.

工作流调度程序仅使用一个线程(非常类似于UI),因此正在运行的任何活动通常都将在同一线程上运行,除非它实现了AsyncCodeActivity,在这种情况下,您只是将调度程序线程交还给运行时等待来自您的AsyncCodeActivity实现调用的任何异步代码的回调时.

The workflow scheduler only uses a single thread (much like UI) so any activity that is running will typically be running on the same thread, unless it implements AsyncCodeActivity, in which case you are simply handing back the scheduler thread to the runtime while waiting for a callback from whichever async code your AsyncCodeActivity implementation is calling.

因此,您确定这是您想要实现的目标吗?您是说要在发送初始响应后运行它吗?在这种情况下,请将您的活动放在发送回复"之后.

Therefore are you sure this is what you want to achieve? Do you mean you want to run it after you have sent your initial response? In this case place your activity after the Send Reply.

如果这些建议不能回答您的问题,请提供更多信息./

Please provide more info if these suggestions don't answer your question./

更新: 最初提出的要求(将实现与服务的接收/发送活动分开)实际上可以通过将目标活动作为服务托管来解决.见以下链接 http://blog.petegoo.com/index.php/2011/09/02/building-an-enterprise-workflow-system-with-wf4/

Update: The original requirement posed (separating implementation from the service Receive/Send activities) may actually be solved by hosting the target activity as a service. See the following link http://blog.petegoo.com/index.php/2011/09/02/building-an-enterprise-workflow-system-with-wf4/

这篇关于异步调用子工作流程活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆