SharpLibEar/ActionSleep.cs
author Stephane Lenclud
Sun, 31 Jul 2016 12:03:52 +0200
changeset 230 8c5cf2228e9a
parent 223 f6272f65d8fc
child 231 4c706feaf706
permissions -rw-r--r--
Published v0.10.2.0.
     1 //
     2 
     3 
     4 using System.Runtime.Serialization;
     5 using System.Threading;
     6 
     7 
     8 namespace SharpLib.Ear
     9 {
    10     
    11 
    12     [DataContract]
    13     [AttributeAction(Id = "Thread.Sleep", Name = "Sleep", Description = "Have the current thread sleep for the specified amount of milliseconds.")]
    14     public class ActionSleep : Action
    15     {
    16         [DataMember]
    17         [AttributeActionProperty
    18             (
    19                 Id = "Thread.Sleep.Timeout",
    20                 Name = "Timeout (ms)",
    21                 Description = "Specifies the number of milliseconds this action will sleep for.",
    22                 Minimum = "0",
    23                 Maximum = "10000",
    24                 Increment =  "1"
    25             )
    26         ]
    27         public int TimeoutInMilliseconds { get; set; }
    28 
    29         public ActionSleep()
    30         {
    31             TimeoutInMilliseconds = 1000;
    32         }
    33 
    34 
    35         public ActionSleep(int aMillisecondsTimeout)
    36         {
    37             TimeoutInMilliseconds = aMillisecondsTimeout;
    38         }
    39 
    40         public override string Brief()
    41         {
    42             return Name + " for " + TimeoutInMilliseconds + " ms";
    43         }
    44 
    45 
    46         protected override void DoExecute()
    47         {
    48             Thread.Sleep(TimeoutInMilliseconds);
    49         }
    50 
    51     }
    52 
    53 
    54 
    55 }