Steven Rosenthal

How does one change the value of a DependencyProperty on a running workflow Thought this should be relatively easy, but I have tried a few things with no luck. I would like to avoid using events if possible. Suggestions Thanks.



Re: Windows Workflow Foundation Set value of DependencyProperty during execution

jdw - MSFT

Do you mean from outside of the workflow You can't directly alter the state of the workflow from the outside, you will need to send an event to the workflow to push data into it.

Thanks,

Joel





Re: Windows Workflow Foundation Set value of DependencyProperty during execution

Steven Rosenthal

Thanks for the response. It does make sense that you would not want to allow direct access into the workflow. But for a state machine (like I am using), you need to add an event handler to each state to intercept the change event (in this case, a deadline extension). That's a bit tedious. It would be nice if the capability to alter property values were built into WF somehow.



Re: Windows Workflow Foundation Set value of DependencyProperty during execution

Jonathan Davlin

Two thoughts.

1. Does it HAVE to be a dependency property for storage, compensation, etc. You can implement your property initialization (while still using dependincy properties) or the getters themselves so that they grab a service that gives them the information. This is the same as a push.

2. If what you don't like is say several states all needing a property to change whenever an event occurs, states can be contained within states. If you place the event handler in the parent state, you then could bind to the parent state's property.






Re: Windows Workflow Foundation Set value of DependencyProperty during execution

Steven Rosenthal

1. Does it HAVE to be a dependency property for storage, compensation, etc. You can implement your property initialization (while still using dependincy properties) or the getters themselves so that they grab a service that gives them the information. This is the same as a push.

It is a deadline value that is checked periodically (in association with different delay activities) so that various reminders can be sent. The DP essentially provides input parameter capability and persistence. Even if I go with another update strategy, I would still need to store the value (e.g. in the database, for instance). But it is an idea worth considering. Thanks.


2. If what you don't like is say several states all needing a property to change whenever an event occurs, states can be contained within states. If you place the event handler in the parent state, you then could bind to the parent state's property.

I remember reading about this capability, but I haven't used it. So the active child state as well as the parent state can both be waiting (concurrently) on their respective sets of events I will look into it. Thanks.





Re: Windows Workflow Foundation Set value of DependencyProperty during execution

Steven Rosenthal

For the sake of closure: FYI, I decided to go with option 2 (the nested state approach). The entire state machine workflow is nested inside a parent state that contains the deadline update event handler. The parent state can still trigger state transitions within the nested workflow, but it does not interfere with its operation. Works perfectly.