Private members in activity: how and where to initialize them ONCE?

I have defined a private boolean in a custom acitivty.

I need to set it when the Execute method is called, but I noticed that every time I execute the activity, the boolean variable is reset.

How can it be possible? Is there a method in which I can perform all private fields initializations, sure that they are done only once during lifetime of my activity?

Thank you very much!

[404 byte] By [jitter123456] at [2007-12-27]
# 1
Sounds like you're looking for overriding Initialize().
TomasRestrepo at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
Sounds good
Thank you very much!

Now, I have a second question: why when I override custom activity's Execute method,
and set a property (already initialized in Initialize() method) with a new value, when I recall the same activity and read the property, the new value is lost?
It seems that only Initialize() makes it to "persist". Is it correct?
Is there a way to set a (private) member
to a new value in Execute method and maintain its value during workflow lifetime?

Thank you very much in advance!

jitter123456 at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3
Sounds like what's going on is that you're seeing different instances of the same activity in a single workflow. Normally, an activity instance (i.e. an object) executes only once. If you have, for example, an activity inside a loop or replicator shape, then actually a new instance of the activity is created for each execution. So, what you might be seeing is that the first time you modify the value of the original instance but the second time around you're dealing with a new, different instance.

You might want to read a bit about spawned contexts in WF, it might clarify some of this.

TomasRestrepo at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

It is the information I needed!

I wonder when I will see a complete MS Windows Workflow Foundation programmers guide.

Thank you!

Jitter

jitter123456 at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified