# HG changeset patch # User StephaneLenclud # Date 1472653473 -7200 # Node ID 3ab73a2a72d8a6da84549446617294c2f08a3a69 # Parent c4749a27966d75f3c0ecebaccdbf64c4b07a1720 Adding Delay action to replace our Sleep action. diff -r c4749a27966d -r 3ab73a2a72d8 SharpLibEar/ActionDelay.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SharpLibEar/ActionDelay.cs Wed Aug 31 16:24:33 2016 +0200 @@ -0,0 +1,53 @@ +// + + +using System.Runtime.Serialization; +using System.Threading; +using System.Threading.Tasks; + +namespace SharpLib.Ear +{ + [DataContract] + [AttributeObject(Id = "Task.Delay", Name = "Delay", Description = "Delay the execution of the next task by the specified amount of milliseconds.")] + public class ActionDelay : Action + { + [DataMember] + [AttributeObjectProperty + ( + Id = "Task.Delay.Milliseconds", + Name = "Delay (ms)", + Description = "Specifies our delay in milliseconds.", + Minimum = "0", + Maximum = "60000", + Increment = "1000" + ) + ] + public int Milliseconds { get; set; } + + public ActionDelay() + { + Milliseconds = 1000; + } + + + public ActionDelay(int aMillisecondsTimeout) + { + Milliseconds = aMillisecondsTimeout; + } + + public override string Brief() + { + return AttributeName + " for " + Milliseconds/1000.0 + " seconds"; + } + + + protected override async Task DoExecute() + { + await Task.Delay(Milliseconds); + } + + } + + + +} \ No newline at end of file diff -r c4749a27966d -r 3ab73a2a72d8 SharpLibEar/ActionSleep.cs --- a/SharpLibEar/ActionSleep.cs Wed Aug 31 16:06:47 2016 +0200 +++ b/SharpLibEar/ActionSleep.cs Wed Aug 31 16:24:33 2016 +0200 @@ -20,8 +20,8 @@ Name = "Timeout (ms)", Description = "Specifies the number of milliseconds this action will sleep for.", Minimum = "0", - Maximum = "10000", - Increment = "1" + Maximum = "60000", + Increment = "1000" ) ] public int TimeoutInMilliseconds { get; set; } diff -r c4749a27966d -r 3ab73a2a72d8 SharpLibEar/SharpLibEar.csproj --- a/SharpLibEar/SharpLibEar.csproj Wed Aug 31 16:06:47 2016 +0200 +++ b/SharpLibEar/SharpLibEar.csproj Wed Aug 31 16:24:33 2016 +0200 @@ -65,6 +65,7 @@ +