author | StephaneLenclud |
Tue, 30 Aug 2016 21:14:18 +0200 | |
changeset 261 | e2729a990e8b |
parent 253 | 2dae7a163fff |
child 264 | 4a08e1b7ba64 |
permissions | -rw-r--r-- |
1 //
4 using System;
5 using System.Collections.Generic;
6 using System.Diagnostics;
7 using System.Runtime.Serialization;
8 using System.Threading;
9 using System.Threading.Tasks;
11 namespace SharpLib.Ear
12 {
13 [DataContract]
14 public abstract class Action: Object
15 {
16 protected abstract Task DoExecute();
18 /// <summary>
19 /// Allows testing from generic edit dialog.
20 /// </summary>
21 public void Test()
22 {
23 Trace.WriteLine("Action test");
24 Execute();
25 }
27 public async Task Execute()
28 {
29 Trace.WriteLine("Action executing: " + Brief());
30 if (!IsValid())
31 {
32 Trace.WriteLine($"WARNING: action invalid, aborting execution.");
33 return;
34 }
36 await DoExecute();
37 }
39 }
42 }