Search

Search:

Namespace:

Search Result
.

The SetState activity transitions a state machine to a new state. In figure 16, we are handling the BugAssigned event. When a bug is assigned, we want to transition to the AssignedState, so we set the TargetStateName property to AssignedState. The AssignedState activity will then have it's own set of Event Driven activities, each with SetState activities to transition to other states (and hopefully one day reach the ClosedState).

.

Use the TargetStateName just as in the standard SetStateActivity to indicate the target state.

.
    Public Shared TargetStateNameProperty As DependencyProperty = DependencyProperty.Register("TargetStateName", GetType(String), GetType(DynamicSetStateActivity))
.
    Public Property TargetStateName() As String
.
            Return (CType((MyBase.GetValue(DynamicSetStateActivity.TargetStateNameProperty)), String))
.
            MyBase.SetValue(DynamicSetStateActivity.TargetStateNameProperty, Value)
.
        Dim e As New SetStateEventArgs(TargetStateName)
.

The SetState activity transitions a state machine to a new state. In figure 16, we are handling the BugAssigned event. When a bug is assigned, we want to transition to the AssignedState, so we set the TargetStateName property to AssignedState. The AssignedState activity will then have it's own set of Event Driven activities, each with SetState activities to transition to other states (and hopefully one day reach the ClosedState).

.

The TargetStateName property of a SetStateActivity cannot be changed at runtime. Use the DynamicSetStateActivity if that kind of behavior is needed.

.

And the second cool behavior is that you can actually execute multiple SetStateActivity objects with different TargetStateName definitions and only the last one will be executed. Again something that might make the logic quite a bit simple as you can set a default TargetStateName at the beginning of your and make changes to the target as exceptional cases arise.

.

Both of these behaviors are especially important as the TargetStateName is a meta property, meaning it cannot be changed at runtime but only at design time. So the option of dynamically changing the SetStateActivity doesn't really exist.