Parallel 建構函式

定義

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

public:
 Parallel();
public Parallel ();
Public Sub New ()

範例

下列程式碼範例將示範如何建立 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.." },
            }
        },

適用於