SharpLibEar/ActionSleep.cs
author StephaneLenclud
Fri, 12 Aug 2016 20:25:05 +0200
changeset 231 4c706feaf706
parent 228 6a84d8282226
child 258 e237c2e33545
permissions -rw-r--r--
Events can now be instantiated.
Action editor is now a generic object editor.
     1 //
     2 
     3 
     4 using System.Runtime.Serialization;
     5 using System.Threading;
     6 
     7 
     8 namespace SharpLib.Ear
     9 {
    10     
    11 
    12     [DataContract]
    13     [AttributeObject(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         [AttributeObjectProperty
    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 }