views:

326

answers:

1

Hi, 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

A: 

1) Even though the generated class is sealed as in

public sealed partial class Workflow1: SequentialWorkflowActivity

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.

Robert Wilczynski