Parallel.CompletionCondition 屬性

定義

在任何分支完成時評估。Evaluates after any branch completes.

public:
 property System::Activities::Activity<bool> ^ CompletionCondition { System::Activities::Activity<bool> ^ get(); void set(System::Activities::Activity<bool> ^ value); };
[System.Windows.Markup.DependsOn("Variables")]
public System.Activities.Activity<bool> CompletionCondition { get; set; }
[<System.Windows.Markup.DependsOn("Variables")>]
member this.CompletionCondition : System.Activities.Activity<bool> with get, set
Public Property CompletionCondition As Activity(Of Boolean)

屬性值

Activity<Boolean>

完成運算式。The completion expression.

屬性

範例

下列程式碼範例將示範如何設定 Parallel 活動的 CompletionCondition 屬性。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.." },
            }
        },

備註

如果此屬性評估為 true ,則會取消集合中的其他已排程元素 BranchesIf this property evaluates to true, then the other scheduled elements in the Branches collection are canceled. 如果並未設定此屬性,則 Activity 集合中所有的 Branches 物件會執行到完成為止。If this property is not set, all Activity objects in the Branches collection execute until completion.

適用於