从另一个工作流运行工作流程工作流、工作流程

2023-09-06 06:56:45 作者:凹凸曼暗恋小怪兽

我目前使用Windows WF连续的工作流程,但需要向上突破的过程,因为我现在有需要共享的功能块多个工作流。我相信,有一种方法来创建自定义的WF code的活动,将基本实现这一点,但我的计划是最终抛弃WF支持无状态的;因此,我不想花时间,现在学习如何code自定义活动。

I am currently using sequential workflows in Windows WF, but need to break up the process because I now have multiple workflows that need to share a piece of functionality. I believe there's a way to create custom code activities in WF that would basically accomplish this, but my plan is to eventually ditch WF in favor of Stateless; therefore, I don't want to spend the time right now learning how to code custom activities.

我唯一能想到的是创建一个新的WF项目包含了所有的共享的行为,然后从需要它们的工作流中启动它们。我在这方面的工作现在就看看怎么回事,但谁能告诉我,如果这仅仅是一个坏主意?

The only thing I can think of is to create a new WF project that contains all of the "shared" behaviors, and then launch them from within the workflows that need them. I'm working on this now to see how it goes, but can anyone tell me if this is just a Bad Idea?

修改 - 一个问题,我看现在的问题是,我用一个单独的WF运行时,因为我已经经历过大规模的内存泄漏,甚至当我处置WF RT的正确。我跟踪所有WF实例在工作流的初始调用者,所以为了妥善处理事件,我不得不通过WF实例名单到工作流程中,因此它可以补充一点,我在国内推出的WF。似乎有点乱给我,但我可以肯定还是尝试这种方式。我跟踪WF实例,因为我想用这个来实现暂停/中止/恢复功能。当用户点击相应的按钮,在图​​形用户界面,它遍历所有的WF实例,并调用匹配的方法。

EDIT -- one "problem" I see right now is that I use a singleton for the WF runtime, as I have experienced massive memory leaks before, even when I dispose of the WF RT properly. I track all WF instances in the initial caller of the workflow, so in order to handle the events properly, I'd have to pass this List of WF instances into the workflow so it can add the WF that I'm launching internally. Seems a bit messy to me, although I can certainly still try it this way. I track the WF instances because I'm trying to use this to enable Pause / Abort / Resume functionality. When the user clicks the respective button in the GUI, it loops over all WF instances and calls the matching method.

推荐答案

您与分裂的工作流为独立的部分主要问题是,他们是完全断开。这是主要的工作流程不等待子工作流来完成。这是可以做到,但需要一些做的事情。

Your main problem with splitting a workflow into separate parts is that they are completely disconnected. That is the main workflow doesn't wait for the child workflows to finish. This can be done but takes some doing.

另一种认为要记住的是错误处理。当一个孩子的工作流故障的主要工作流程是没有意识到这一点,完全不同的行为,从增加孩子的活动。

Another think to keep in mind is error handling. When a child workflow faults the main workflow is not aware of this, quite different behavior from adding child activities.

如果您需要重用的逻辑,你还可以创建使用设计的复合活动。这是非常相似的开发工作流并且可以根据需要在多个工作流重用这些活动

If you need to reuse logic you can also create composite activities using the designer. This is very similar to developing workflows and you can reuse these activities on multiple workflows as needed.