1
//
2
3
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;
10
11
namespace SharpLib.Ear
12
{
13
[DataContract]
14
public abstract class Action: Object
15
16
protected abstract Task DoExecute();
17
18
/// <summary>
19
/// Allows testing from generic edit dialog.
20
/// </summary>
21
public void Test()
22
23
Trace.WriteLine("Action test");
24
Execute();
25
}
26
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
35
36
await DoExecute();
37
38
39
40
41
42