Represents a state in a StateMachineWorkflowActivity.
Assembly: System.Workflow.Activities (in System.Workflow.Activities.dll)
'Declaration <ToolboxBitmapAttribute(GetType(StateActivity), "Resources.StateActivity.png")> _ <ComVisibleAttribute(False)> _ <ActivityValidatorAttribute(GetType(StateActivityValidator))> _ Public Class StateActivity _ Inherits CompositeActivity 'Usage Dim instance As StateActivity
The represents a State in a StateMachineWorkflowActivity. State activities could contain one or more EventDrivenActivity, or classes, one StateInitializationActivity class, and one StateFinalizationActivity class. SetState activities are used inside an EventHandlersActivity and StateInitializationActivity to move the state of the workflow.
When a is executing, the only events that can be received are the events that can be handled by the EventDrivenActivity activities in the and also the EventDrivenActivity activities attached to the enclosing activities and the root Activity.
When the starts running, the will check to see whether a StateInitializationActivity activity is present or not. The can have zero or one StateInitializationActivity activity. If a StateInitializationActivity activity is present the StateInitializationActivity will be executed. As soon as the StateInitializationActivity activity finishes, the blocks events so that the only receives events that can be handled by its EventDrivenActivity activities.
The is a CompositeActivity, meaning the activity can contain other activities.
The following code example shows how to create a new instance of the class and use it implement a simple state machine to transition between 3 states. This code example is part of the SimpleStateMachineWorkflow SDK sample from the StateMachineWorkflow.cs file. For more information, see Simple State Machine.
Me.WhileLoop = New System.Workflow.Activities.WhileActivity() Me.Parallel = New System.Workflow.Activities.ParallelActivity() Me.Sequence1 = New System.Workflow.Activities.SequenceActivity() Me.Sequence2 = New System.Workflow.Activities.SequenceActivity() Me.ConsoleMessage1 = New System.Workflow.Activities.CodeActivity() Me.ConsoleMessage2 = New System.Workflow.Activities.CodeActivity() ' ' WhileLoop ' Me.WhileLoop.Activities.Add(Me.Parallel) AddHandler codecondition1.Condition, AddressOf Me.WhileCondition Me.WhileLoop.Condition = codecondition1 Me.WhileLoop.Name = "WhileLoop" ' ' Parallel ' Me.Parallel.Activities.Add(Me.Sequence1) Me.Parallel.Activities.Add(Me.Sequence2) Me.Parallel.Name = "Parallel"
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003