共用方式為


Parallel 建構函式

定義

建立 Parallel 活動的新執行個體。

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

範例

下列程式碼範例將示範如何建立 Parallel 活動。

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.." },
            }
        },

適用於