Parallel.Branches Property

.NET Framework (current version)
 

The child elements to be executed in parallel.

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

[DependsOnAttribute("CompletionCondition")]
public Collection<Activity> Branches { get; }

Property Value

Type: System.Collections.ObjectModel.Collection<Activity>

The elements.

The following code sample demonstrates setting the Branches property of a Parallel activity. This example is from the Cancellation Handler on Compensable Activity sample.

return new Parallel
{
    // Timeout from branch causes other branch to cancel.
    CompletionCondition = true,

    Branches =
    {
        // Delay Branch
        new Sequence
        {
            Activities =
            {
                new WriteLine { Text = "Branch1: Body is about to Delay 2secs transferring execution to Branch2" },
                new Delay
                {
                    Duration = TimeSpan.FromSeconds(2)
                },
                new WriteLine { Text = "Branch1: Body is about to complete causing Branch2 to cancel.." },
            }
        },

.NET Framework
Available since 4.0
Return to top
Show: