PickBranch Class
TOC
Collapse the table of content
Expand the table of content

PickBranch Class

.NET Framework (current version)
 

A potential path of execution within a Pick activity.

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

System.Object
  System.Activities.Statements.PickBranch

[ContentPropertyAttribute("Action")]
public sealed class PickBranch

NameDescription
System_CAPS_pubmethodPickBranch()

Creates a new instance of the PickBranch activity.

NameDescription
System_CAPS_pubpropertyAction

The Activity to execute if this branch is triggered for execution.

System_CAPS_pubpropertyDisplayName

The name of this branch to be displayed in the activity designer.

System_CAPS_pubpropertyTrigger

The activity whose completion activates this pick branch.

System_CAPS_pubpropertyVariables

The collection of user-defined variables associated with this activity.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

A PickBranch contains a Trigger and an Action. At the beginning of a Pick element’s execution, all the trigger activities from all PickBranch elements are scheduled. When the first (leftmost) activity completes, the corresponding action activity is scheduled, and all other trigger activities are canceled.

The following code sample demonstrates creating a PickBranch activity. This example is from the Using the Pick Activity sample.

static Activity CreateWF()
{
    Variable<string> name = new Variable<string>();
    Sequence body = new Sequence
    {
        Variables = { name },
        Activities = 
        {
            new WriteLine { Text = "What is your name? (You have 5 seconds to answer)" },
            new Pick
            {
               Branches = 
               {
                   new PickBranch
                    {
                       Trigger = new ReadString
                       {
                           Result = name,
                           BookmarkName = bookmarkName
                       },
                       Action = new WriteLine 
                       { 
                           Text = new InArgument<string>(env => "Hello " + name.Get(env)) 
                       }
                   },
                   new PickBranch
                    {
                       Trigger = new Delay
                       {
                           Duration = TimeSpan.FromSeconds(5)
                       },
                       Action = new WriteLine
                       {
                           Text = "Time is up."
                       }
                   }
               }
           }
       }
    };

    return body;
}

.NET Framework
Available since 4.0

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

Return to top
Show:
© 2016 Microsoft