Parallel.CompletionCondition Property

.NET Framework (current version)
 

Evaluates after any branch completes.

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

[DependsOnAttribute("Variables")]
public Activity<bool> CompletionCondition { get; set; }

Property Value

Type: System.Activities.Activity<Boolean>

The completion expression.

If this property evaluates to true, then the other scheduled elements in the Branches collection are canceled. If this property is not set, all Activity objects in the Branches collection execute until completion.

The following code sample demonstrates setting the CompletionCondition 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: