Parallel 類別

定義

同時或非同步執行所有子活動的活動。An activity that executes all child activities simultaneously and asynchronously.

public ref class Parallel sealed : System::Activities::NativeActivity
[System.Windows.Markup.ContentProperty("Branches")]
public sealed class Parallel : System.Activities.NativeActivity
type Parallel = class
    inherit NativeActivity
Public NotInheritable Class Parallel
Inherits NativeActivity
繼承
屬性

範例

下列程式碼範例將示範如何建立 Parallel 活動。The following code sample demonstrates creating 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.." },
            }
        },

備註

Parallel 活動會透過在開始時同時排定其 Activity 集合中的各個 Branches 來操作。A Parallel activity operates by simultaneously scheduling each Activity in its Branches collection at the start. 當所有Branches完整或其CompletionCondition屬性評估為true時, 它就會完成。It completes when all of its Branches complete or when its CompletionCondition property evaluates to true. 所有 Activity 物件非同步執行時,這些物件不會以個別的執行緒執行,因此每個後續的活動都只會在先前排程的活動完成或閒置時才會執行。While all the Activity objects run asynchronously, they do not execute on separate threads, so each successive activity only executes when the previously scheduled activity completes or goes idle. 如果此活動沒有閒置的子活動,則會使用與執行 Sequence 活動相同的方式來執行此活動。If none of the child activities of this activity go idle, this activity execute in the same way that a Sequence activity does.

建構函式

Parallel()

建立 Parallel 活動的新執行個體。Creates a new instance of the Parallel activity.

屬性

Branches

要平行執行的子項目。The child elements to be executed in parallel.

CacheId

取得工作流程定義範圍內的唯一快取識別碼。Gets the identifier of the cache that is unique within the scope of the workflow definition.

(繼承來源 Activity)
CanInduceIdle

取得或設定值,這個值指出此活動是否會造成工作流程變為閒置。Gets or sets a value that indicates whether the activity can cause the workflow to become idle.

(繼承來源 NativeActivity)
CompletionCondition

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

Constraints

取得 Constraint 活動的集合,這些活動可以設定為提供 Activity 的驗證。Gets a collection of Constraint activities that can be configured to provide validation for the Activity.

(繼承來源 Activity)
DisplayName

取得或設定選擇性的易記名稱,這個名稱會用於偵錯、驗證、例外狀況處理及追蹤。Gets or sets an optional friendly name that is used for debugging, validation, exception handling, and tracking.

(繼承來源 Activity)
Id

取得工作流程定義範圍內的唯一識別碼。Gets an identifier that is unique in the scope of the workflow definition.

(繼承來源 Activity)
Implementation

活動的執行邏輯。The execution logic of the activity.

(繼承來源 NativeActivity)
ImplementationVersion

取得或設定活動的實作版本。Gets or sets the implementation version of the activity.

(繼承來源 NativeActivity)
Variables

包含的變數集合。The collection of contained variables.

方法

Abort(NativeActivityAbortContext)

在衍生類別中實作時,會採取動作以回應中止的活動。When implemented in a derived class, takes actions in response to the activity being aborted.

(繼承來源 NativeActivity)
CacheMetadata(ActivityMetadata)

未實作。Not implemented. 請改用 CacheMetadata(NativeActivityMetadata) 方法。Use the CacheMetadata(NativeActivityMetadata) method instead.

(繼承來源 NativeActivity)
CacheMetadata(NativeActivityMetadata)

建立並驗證活動引數、變數、子活動和活動委派的描述。Creates and validates a description of the activity's arguments, variables, child activities, and activity delegates.

(繼承來源 NativeActivity)
Cancel(NativeActivityContext)

在衍生類別中實作時,執行邏輯以便在非失誤性的狀況下及早完成活動。When implemented in a derived class, runs logic to cause graceful early completion of the activity.

(繼承來源 NativeActivity)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Execute(NativeActivityContext)

在衍生類別中實作時,執行活動的執行邏輯。When implemented in a derived class, runs the activity's execution logic.

(繼承來源 NativeActivity)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnCreateDynamicUpdateMap(NativeActivityUpdateMapMetadata, Activity)

建立動態更新的對應時引發事件。Raises an event when creating a map for the dynamic update.

(繼承來源 NativeActivity)
OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity)

建立動態更新的對應時引發事件。Raises an event when creating a map for the dynamic update.

(繼承來源 NativeActivity)
ShouldSerializeDisplayName()

指出是否應序列化 DisplayName 屬性。Indicates whether the DisplayName property should be serialized.

(繼承來源 Activity)
ToString()

傳回包含 StringIdDisplayNameActivityReturns a String that contains the Id and DisplayName of the Activity.

(繼承來源 Activity)
UpdateInstance(NativeActivityUpdateContext)

更新 NativeActivity 的執行個體。Updates the instance of NativeActivity.

(繼承來源 NativeActivity)

適用於