StephaneLenclud@263: // StephaneLenclud@263: StephaneLenclud@263: StephaneLenclud@263: using System.Runtime.Serialization; StephaneLenclud@263: using System.Threading; StephaneLenclud@263: using System.Threading.Tasks; StephaneLenclud@263: StephaneLenclud@263: namespace SharpLib.Ear StephaneLenclud@263: { StephaneLenclud@263: [DataContract] StephaneLenclud@265: [AttributeObject(Id = "Action.Task.Delay", Name = "Delay", Description = "Delay the execution of the next task.")] StephaneLenclud@263: public class ActionDelay : Action StephaneLenclud@263: { StephaneLenclud@263: [DataMember] StephaneLenclud@263: [AttributeObjectProperty StephaneLenclud@263: ( StephaneLenclud@263: Id = "Task.Delay.Milliseconds", StephaneLenclud@263: Name = "Delay (ms)", StephaneLenclud@265: Description = "Specifies the delay in milliseconds.", StephaneLenclud@263: Minimum = "0", StephaneLenclud@263: Maximum = "60000", StephaneLenclud@263: Increment = "1000" StephaneLenclud@263: ) StephaneLenclud@263: ] StephaneLenclud@263: public int Milliseconds { get; set; } StephaneLenclud@263: StephaneLenclud@263: public ActionDelay() StephaneLenclud@263: { StephaneLenclud@263: Milliseconds = 1000; StephaneLenclud@263: } StephaneLenclud@263: StephaneLenclud@263: StephaneLenclud@263: public ActionDelay(int aMillisecondsTimeout) StephaneLenclud@263: { StephaneLenclud@263: Milliseconds = aMillisecondsTimeout; StephaneLenclud@263: } StephaneLenclud@263: StephaneLenclud@264: public override string BriefBase() StephaneLenclud@263: { StephaneLenclud@263: return AttributeName + " for " + Milliseconds/1000.0 + " seconds"; StephaneLenclud@263: } StephaneLenclud@263: StephaneLenclud@263: StephaneLenclud@263: protected override async Task DoExecute() StephaneLenclud@263: { StephaneLenclud@263: await Task.Delay(Milliseconds); StephaneLenclud@263: } StephaneLenclud@263: StephaneLenclud@263: } StephaneLenclud@263: StephaneLenclud@263: StephaneLenclud@263: StephaneLenclud@263: }