Using Conditions in Workflows

Using Conditions in Workflows

You can use conditions to control the behavior of your workflow. The run-time engine evaluates a condition and then acts based on the result of that evaluation.

There are two ways to represent conditions in your workflow:

  • You can express conditions in code by writing a handler that sets the Result property for your condition.

  • You can also express conditions as a rule condition, which is a System.CodeDom expression in your rule file.

Conditional Activities

Several activities that are provided with the Windows Workflow Foundation use conditions:

  • The first IfElseBranchActivity, contained within an IfElseActivity activity, which has a condition that evaluates to true is executed.

  • The WhileActivity activity continuously executes any activities contained within it, as long as its condition evaluates to true. The condition is reevaluated at the completion of each loop.

  • The ConditionedActivityGroup continuously executes any activities within it until its condition evaluates to true. Each individual activity within the ConditionedActivityGroup has a When condition that is set using the WhenConditionProperty. Each activity executes only when the When condition evaluates to true.

  • The ReplicatorActivity completes its execution when its UntilCondition property evaluates to true.

You can also use conditions in custom activities that you create.

ms734614.note(en-us,VS.90).gifNote:
Rule conditions and code conditions can refer to public, private, and internal members defined on your workflow class. When using declarative rules or activity conditions it is recommended to reference public members of the workflow class. This resolves compiler warnings that may appear when private members are declared in the workflow but used only in declarative rules or activity conditions.

In This Section

How to: Use Conditions Through Code
Describes how to create conditions in C# or Visual Basic.

How to: Use Rule Conditions in Workflows
Describes how to use conditions to drive the execution behavior of activities.

Workflow Changes to Rule Conditions
Describes how to use workflow changes to change rule condition definitions.

CodeDom Types Supported by Windows Workflow Foundation
Describes how to use CodeDom types to author conditions.

Rule Changes in .NET Framework 3.5
Contains topics that discuss rule changes for .NET Framework 3.5.

See Also

Community Additions

ADD
Show:
© 2016 Microsoft