SharpLibEar/ActionDelay.cs
author StephaneLenclud
Sat, 07 Jan 2017 20:21:42 +0100
changeset 277 71ba0dd622a5
parent 264 4a08e1b7ba64
permissions -rw-r--r--
Created Audio Manager class.
Clean up CScore audio usage.
Fixing broken audio device change handler.
Fixed various audio Dispose deadlock due to Invoke usage.
Thus now using BeginInvoke instead.
     1 //
     2 
     3 
     4 using System.Runtime.Serialization;
     5 using System.Threading;
     6 using System.Threading.Tasks;
     7 
     8 namespace SharpLib.Ear
     9 {
    10     [DataContract]
    11     [AttributeObject(Id = "Action.Task.Delay", Name = "Delay", Description = "Delay the execution of the next task.")]
    12     public class ActionDelay : Action
    13     {
    14         [DataMember]
    15         [AttributeObjectProperty
    16             (
    17                 Id = "Task.Delay.Milliseconds",
    18                 Name = "Delay (ms)",
    19                 Description = "Specifies the delay in milliseconds.",
    20                 Minimum = "0",
    21                 Maximum = "60000",
    22                 Increment = "1000"
    23             )
    24         ]
    25         public int Milliseconds { get; set; }
    26 
    27         public ActionDelay()
    28         {
    29             Milliseconds = 1000;
    30         }
    31 
    32 
    33         public ActionDelay(int aMillisecondsTimeout)
    34         {
    35             Milliseconds = aMillisecondsTimeout;
    36         }
    37 
    38         public override string BriefBase()
    39         {
    40             return AttributeName + " for " + Milliseconds/1000.0 + " seconds";
    41         }
    42 
    43 
    44         protected override async Task DoExecute()
    45         {
    46             await Task.Delay(Milliseconds);
    47         }
    48 
    49     }
    50 
    51 
    52 
    53 }