views:

70

answers:

1

Is it possible to control this nasty behavior? I'm trying to execute() some stateful activity I wrote (activity that increment an index on each execution) inside a loop (While) activity. WF engine is cloning my activity on each iteration. Since the clone is made from a template activity and not from the latest cloned one, the index property is being reset. My goal is to run the while activity, and after it to call some PrintActivty that will print my own activity's index. I have tried to go with the dirty way and updating the template, it works for first level nesting, but when I try to run while inside while it doesn't work.

p.s. - i'm getting the template from my activity's Execute():

   var template = this.WFActivity.GetActivityByName(this.QualifiedName);

WFActivity is a property set to point on the WF root activity.

+1  A: 

You can't disable activity cloning as it is an inherent part of how activities are executed.

The way to work around this is to use an dependency property in you activity to store the index value. Now in the workflow you can bind the index property to a property or field at a higher level, like the workflow itself, and the value will be stored there instead of in the cloned copy of you activity.

Maurice