This documentation is archived and is not being maintained.

SetStateActivity Class

Provides the transition to a StateActivity in a state machine workflow. This class cannot be inherited.

Namespace:  System.Workflow.Activities
Assembly:  System.Workflow.Activities (in System.Workflow.Activities.dll)

[ToolboxBitmapAttribute(typeof(SetStateActivity), "Resources.SetStateActivity.png")]
public sealed class SetStateActivity : Activity

The SetStateActivity can be used only in state machine workflows.

The SetStateActivity provides transitions only to leaf StateActivity activities (a StateActivity that does not contain other StateActivity activities).

The SetStateActivity only provides transitions between two StateActivity classes and does not support StateActivity to parent StateActivity transitions or any other combination.

The SetStateActivity has to be a leaf node within the activity tree of an event handler.

There can be more than one SetStateActivity but all the activities must be leaf nodes.

SetStateActivity is always the last activity in the run path of a EventDrivenActivity activity.

The following code example shows how to create a new instance of the SetStateActivity 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.

this.WhileLoop = new System.Workflow.Activities.WhileActivity();
this.Parallel = new System.Workflow.Activities.ParallelActivity();
this.Sequence1 = new System.Workflow.Activities.SequenceActivity();
this.Sequence2 = new System.Workflow.Activities.SequenceActivity();
this.ConsoleMessage1 = new System.Workflow.Activities.CodeActivity();
this.ConsoleMessage2 = new System.Workflow.Activities.CodeActivity();
// WhileLoop 
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.WhileCondition);
this.WhileLoop.Condition = codecondition1;
this.WhileLoop.Name = "WhileLoop";
// Parallel 
this.Parallel.Name = "Parallel";

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0