Pick activity (build in activity sample)

Source: Internet
Author: User

the pick activity provides event-based control modeling. it behaves similar to the C # switch statement, which executes only one of the branches in the switch statement. unlike the switch statement in which a branch is executed based upon on a value, the pick activity executes a branch based upon how an activity completes.

This sample prompts a user to type in their name on the console within a given time period. the pick activity in the sample has two branches that are executed based upon whether the user types in their name within 5 seconds or not. if the user types in their name within 5 seconds, the first branch is executed, which contains a customReadlineActivity; otherwise the other branch is executed, which contains a delay activity. once a user's name is typed in on the console, the user's name is printed on the console. if an input is not entered within 5 seconds, the operation is timed out.

 

 

Here comes the msdn definition of pick activity:

Schedules all child pickbranch activities and cancels all but the first to have its trigger complete. the pickbranch activity has both a trigger and an action; each is an activity. when a trigger activity completes, the pick cancels all its other child activities. 

According to my understanding and actual running examples, Let me know:

Here we need to understand the meaning of schedule. In fact, it will schedule all triggers under pickbranch to run simultaneously. Each pickbranch is like a 200-meter track for N people. Trigger can be understood as a half-process goal for everyone. Maybe a's half-process goal is 50 meters, B's is 75 meters, and so on. The speed of A and B is not the same. However, it is certain that, in fact, the first half-course person is allowed to continue his 200-meter race, and at the same time, it will cancel the 200-meter race for all others.

In combination, the trigger on the right is a latency, which is assumed to be 5 seconds. No matter what the trigger on the left is, it can be completed five seconds ago, the complete branch on the left is executed. Otherwise, the opposite is performed.

As msdn says, it is indeed like a switch.For personal understanding, please kindly advise. Thank you.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.