SharpLibEar/ActionCallback.cs
author StephaneLenclud
Sun, 26 Feb 2017 18:00:10 +0100
changeset 280 f90d1e101932
parent 228 6a84d8282226
permissions -rw-r--r--
Published v1.4.5
Disable static display layout in release build.
StephaneLenclud@210
     1
//
StephaneLenclud@210
     2
StephaneLenclud@210
     3
using System.Runtime.Serialization;
StephaneLenclud@258
     4
using System.Threading.Tasks;
StephaneLenclud@210
     5
StephaneLenclud@210
     6
namespace SharpLib.Ear
StephaneLenclud@210
     7
{
StephaneLenclud@210
     8
    [DataContract]
StephaneLenclud@210
     9
    public abstract class ActionCallback : Action
StephaneLenclud@210
    10
    {
StephaneLenclud@210
    11
        public delegate void Delegate();
StephaneLenclud@210
    12
StephaneLenclud@210
    13
        private readonly Delegate iCallback;
StephaneLenclud@210
    14
StephaneLenclud@210
    15
        public ActionCallback(Delegate aCallback = null)
StephaneLenclud@210
    16
        {
StephaneLenclud@210
    17
            iCallback = aCallback;
StephaneLenclud@210
    18
        }
StephaneLenclud@210
    19
StephaneLenclud@258
    20
        protected override async Task DoExecute()
StephaneLenclud@210
    21
        {
StephaneLenclud@210
    22
            if (iCallback != null)
StephaneLenclud@210
    23
            {
StephaneLenclud@210
    24
                iCallback.Invoke();
StephaneLenclud@210
    25
            }            
StephaneLenclud@210
    26
        }
StephaneLenclud@210
    27
    }
StephaneLenclud@210
    28
StephaneLenclud@210
    29
}