同时执行一些自定义活动的最佳方法是什么? [英] What is the best way to execute a few custom activities concurrently?

查看:79
本文介绍了同时执行一些自定义活动的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在AsyncCodeActivity,NativeActivityContext.ScheduleAction等上看到了很多东西,并且链接/视频到各种停留在WF4上的东西可以同时执行活动,但对于我来说却并不在一起.我基本上有3个自定义活动,并且我想同时执行这三个活动.

这三个活动基本上是从文件中读取数据并将数据加载到它们自己的db表中.我首先尝试使用Parallel活动,然后将这三个活动放到三个独立的分支中.显然,尽管并行活动仅在其运行的分支进入空闲状态后才移至下一个分支.

通过设计人员,我如何同时执行三个活动?我是否需要创建某种自定义活动来包装要调用的每个活动?如果是这样,那看起来像什么?指导/协助将不胜感激.谢谢!


刀片不需要重新加载...

I've seen quite a bit of stuff on AsyncCodeActivity, NativeActivityContext.ScheduleAction, etc. and links/videos to all kinds of stuff staying WF4 can execute activities concurrently but it's not coming together for me. I basically have 3 custom activities and I want to execute all three concurrently.

These three activities basically read data out of a file and load the data into their own db table. I first tried using the Parallel activity and dropped the three activities into three seperate branches. Apparently though the Parallel activity only moves onto the next branch once the branch it's operating on goes Idle.

Via the designer, how do I execute three activities concurrently? Do I need to create some sort of custom activites that wraps each activity I want to call? If so what does that look like? Guidance/assistance would be greatly appreciated. Thanks!


Blades Don't Need Reloading...

推荐答案

詹姆斯,

您是否尝试过子类化AsyncCodeActivity的方法了吗?并行活动应适用于并行运行任务,但前提是必须以非阻塞方式编写活动,该方式旨在通过AsyncCodeActivity轻松实现.

MSDN拥有此示例

http://msdn.microsoft.com/en-us /library/ee358731(VS.100).aspx

该示例中的重要一点是将WF运行时中的AsyncCallback传递给BeginExecute()中的异步工作的方式,这样它就可以在完成运行时回叫运行时.

Tim
Hi James,

Have you tried the subclassing AsyncCodeActivity approach yet? Parallel Activity should work for running tasks in parallel, but only if the activities are written in a non-blocking way which is designed to be easy to do through AsyncCodeActivity.

MSDN has this sample

http://msdn.microsoft.com/en-us/library/ee358731(VS.100).aspx

An important point in the sample is the way you pass the AsyncCallback from the WF runtime to the async work in BeginExecute(), so that it can call the runtime back when it finishes doing whatever it was doing.

Tim


这篇关于同时执行一些自定义活动的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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