次の方法で共有


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.

Note

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

See Also

Reference

ConditionedActivityGroup
IfElseBranchActivity
PolicyActivity
ReplicatorActivity
WhileActivity
System.Workflow.Activities.Rules

Concepts

Using the PolicyActivity Activity

Other Resources

Developing Workflows