SharpLibEar/ActionCallback.cs
author StephaneLenclud
Tue, 30 Aug 2016 03:45:45 +0200
changeset 258 e237c2e33545
parent 228 6a84d8282226
permissions -rw-r--r--
Published v1.1.0.0.
EAR is now async.
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
}