Pick

When to use Pick

The Pick activity simplifies the modeling of a set of event triggers followed by their corresponding handlers. A Pick activity contains a collection of PickBranch activities, where each PickBranch is a pairing between a Trigger activity and an Action activity. At execution time, the triggers for all branches are executed in parallel. When one trigger completes, then its corresponding action is executed, and all other triggers are canceled.

Figure 1

pick1

Scenario

The following screenshot shows a pick activity with two branches. One branch has a trigger called Read input, a custom activity that reads input from the command line. The second branch has a Delay activity trigger. If the Read input activity receives data before the Delay activity finishes, Delay will be canceled, and a greeting will be written to the console. Otherwise, if the Read input activity does not receive data in the allotted time, then it will be canceled, and a timeout message will be written to the console. This is a common pattern used to add a timeout to any action.

Figure 2

Pick2

v4.0.0