views:

317

answers:

1

Hi All,

I have a simple custom activity with a private member variable (integer).

When i put it inside a sequence activity which is inside a while activity and start iterating i have a problem:

My member variable is zeroed in each iteration even though i increment it by one every time the activity is executed.

What am i doing wrong?

Thanks,

Adi Barda

+2  A: 

Without seeing the code it is hard to say, but when you are working inside of a While activity you have to be careful how you modify state on your child activities. The While activity spawns multiple execution execution contexts and will clone your activity from a template (in other words - you aren't executing the same activity multiple times, the workflow creates multiple instances of your custom activity). See: http://blogs.msdn.com/advancedworkflow/archive/2006/03/21/557121.aspx and http://msdn.microsoft.com/en-us/magazine/cc163414.aspx

OdeToCode