MS Workflow Foundation 继承和 while 活动
我有两个问题。 1.为什么工作流类是“SEALED”类? 继承工作流程是一种不好的做法吗? 2. while活动缓慢。 IE。: 我按照这个顺序将 3 个活动放在一个连续的 wf 上...... 代码_活动1 while_activity Code_activity2(在 while 活动中)
Code_activity1 - 将 int 计数器设置为 33320。 While_activity - 循环直到 counter > 0。 Code_activity2 - 将计数器减 1(计数器--);
现在的问题是执行整个工作流程花费的时间太长(大约 20 分钟)!
如果我在代码上手工做同样的事情:,
int counter = 33320;
while(counter>0)
counter--;
大约需要 1 毫秒。
为什么 while 活动这么慢?
谢谢
I have two questions.
1. Why is workflow class "SEALED" class? Is it a bad practice to inherit workflows?
2. The while activity is slow.
IE.:
I put 3 activities on a seqential wf in this order...
Code_activity1
While_activity
Code_activity2 (in the while activity)
Code_activity1 - sets an int counter to 33320.
While_activity - loops until counter > 0.
Code_activity2 - decrements counter by 1 (counter--);
Now the problem is that is taking too long to execute the entire workflow (about 20 minutes)!!!
If I do the same thing by hand on code:,
int counter = 33320;
while(counter>0)
counter--;
It takes about 1 millisecond.
Why is the while activity so slow?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1)即使生成的类是密封的,因为
没有什么真正阻止您删除密封关键字并从中继承。 我猜您通常不想继承您设计的工作流程,据说密封可以给您带来一些性能优势
2) http://msdn.microsoft.com/en-us/library/ms735819.aspx 解释了 while 活动的工作原理。 您添加了所提到的子活动 33320 次创建、在活动执行/初始化等时触发的所有事件以及工作流运行时需要处理的所有其他工作,您将获得 20 分钟的时间。
1) Even though the generated class is sealed as in
nothing really stops you from removing the sealed keyword and inherit from it. I guess you usually don't want to inherit from the workflow you design and sealed is said to give you some performance benefits
2) http://msdn.microsoft.com/en-us/library/ms735819.aspx explains a little bit how while activity works. You add the mentioned creatio of the child activity 33320 times, all events that fire on activity execution / initialization etc. and all the additional work that workflow runtime needs to handle and you get your 20 minutes.