Delay.Duration 属性

定义

Delay 活动创建的计时器的持续时间。 如果持续时间设置为 MaxValue,则延迟为无限。

public:
 property System::Activities::InArgument<TimeSpan> ^ Duration { System::Activities::InArgument<TimeSpan> ^ get(); void set(System::Activities::InArgument<TimeSpan> ^ value); };
[System.Activities.RequiredArgument]
public System.Activities.InArgument<TimeSpan> Duration { get; set; }
[<System.Activities.RequiredArgument>]
member this.Duration : System.Activities.InArgument<TimeSpan> with get, set
Public Property Duration As InArgument(Of TimeSpan)

属性值

计时器持续时间。

属性

示例

下面的代码示例演示如何在 Delay 活动中使用 Duration。 此示例摘自 使用选取活动 示例。

static Activity CreateWF()
{
    Variable<string> name = new Variable<string>();
    Sequence body = new Sequence
    {
        Variables = { name },
        Activities =
        {
            new WriteLine { Text = "What is your name? (You have 5 seconds to answer)" },
            new Pick
            {
               Branches =
               {
                   new PickBranch
                    {
                       Trigger = new ReadString
                       {
                           Result = name,
                           BookmarkName = bookmarkName
                       },
                       Action = new WriteLine
                       {
                           Text = new InArgument<string>(env => "Hello " + name.Get(env))
                       }
                   },
                   new PickBranch
                    {
                       Trigger = new Delay
                       {
                           Duration = TimeSpan.FromSeconds(5)
                       },
                       Action = new WriteLine
                       {
                           Text = "Time is up."
                       }
                   }
               }
           }
       }
    };

    return body;
}

适用于