Delay::Duration Property

.NET Framework (current version)
 

The duration of the timer that the Delay activity creates. If the duration is set to P:System.TimeSpan.MaxValue, the delay is infinite.

Namespace:   System.Activities.Statements
Assembly:  System.Activities (in System.Activities.dll)

public:
[RequiredArgumentAttribute]
property InArgument<TimeSpan>^ Duration {
	InArgument<TimeSpan>^ get();
	void set(InArgument<TimeSpan>^ value);
}

Property Value

Type: System.Activities::InArgument<TimeSpan>^

The timer duration.

The following code sample demonstrates using Duration in a Delay activity. This example is from the Using the Pick Activity sample.

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;
}

.NET Framework
Available since 4.0
Return to top
Show: