# HG changeset patch
# User StephaneLenclud
# Date 1472521545 -7200
# Node ID e237c2e3354527241af76e4f41aed48ff594f3b9
# Parent 3f1d16d233dc45854bee844165472d97e3954011
Published v1.1.0.0.
EAR is now async.
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecActiveSource.cs
--- a/Server/Actions/ActionCecActiveSource.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecActiveSource.cs Tue Aug 30 03:45:45 2016 +0200
@@ -26,7 +26,7 @@
///
/// Set the defined device type as active source.
///
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecClose.cs
--- a/Server/Actions/ActionCecClose.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecClose.cs Tue Aug 30 03:45:45 2016 +0200
@@ -14,7 +14,7 @@
[AttributeObject(Id = "Cec.Close", Name = "CEC Close", Description = "Close CEC connection.")]
class ActionCecClose : SharpLib.Ear.Action
{
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecDevicePowerOn.cs
--- a/Server/Actions/ActionCecDevicePowerOn.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecDevicePowerOn.cs Tue Aug 30 03:45:45 2016 +0200
@@ -27,7 +27,7 @@
///
///
///
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecDeviceStandby.cs
--- a/Server/Actions/ActionCecDeviceStandby.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecDeviceStandby.cs Tue Aug 30 03:45:45 2016 +0200
@@ -27,7 +27,7 @@
///
///
///
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecInactiveSource.cs
--- a/Server/Actions/ActionCecInactiveSource.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecInactiveSource.cs Tue Aug 30 03:45:45 2016 +0200
@@ -14,7 +14,7 @@
[AttributeObject(Id = "Cec.InactiveSource", Name = "CEC Inactive Source", Description = "Set this CEC device as inactive source.")]
class ActionCecInactiveSource : SharpLib.Ear.Action
{
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecOpen.cs
--- a/Server/Actions/ActionCecOpen.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecOpen.cs Tue Aug 30 03:45:45 2016 +0200
@@ -14,7 +14,7 @@
[AttributeObject(Id = "Cec.Open", Name = "CEC Open", Description = "Open CEC connection.")]
class ActionCecOpen : SharpLib.Ear.Action
{
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecScan.cs
--- a/Server/Actions/ActionCecScan.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecScan.cs Tue Aug 30 03:45:45 2016 +0200
@@ -15,7 +15,7 @@
[AttributeObject(Id = "Cec.Scan", Name = "CEC Scan", Description = "Scan devices on your CEC HDMI network.")]
class ActionCecScan : SharpLib.Ear.Action
{
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecUserControlPressed.cs
--- a/Server/Actions/ActionCecUserControlPressed.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecUserControlPressed.cs Tue Aug 30 03:45:45 2016 +0200
@@ -57,7 +57,7 @@
///
///
///
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionCecUserControlReleased.cs
--- a/Server/Actions/ActionCecUserControlReleased.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionCecUserControlReleased.cs Tue Aug 30 03:45:45 2016 +0200
@@ -49,7 +49,7 @@
///
///
///
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (Cec.Client.Static == null)
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionDisplayMessage.cs
--- a/Server/Actions/ActionDisplayMessage.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionDisplayMessage.cs Tue Aug 30 03:45:45 2016 +0200
@@ -66,7 +66,7 @@
///
///
///
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
StartMessageClient();
}
diff -r 3f1d16d233dc -r e237c2e33545 Server/Actions/ActionHarmonyCommand.cs
--- a/Server/Actions/ActionHarmonyCommand.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/Actions/ActionHarmonyCommand.cs Tue Aug 30 03:45:45 2016 +0200
@@ -69,17 +69,12 @@
///
///
///
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
- //Fire and forget our command
- //TODO: check if the harmony client connection is opened
if (Program.HarmonyClient!=null)
{
- // Wait synchronously for now until we figure out how we could do async stuff in EAR.
- // TODO: Have an abort option in EAR. For instance we don't want to keep sending Harmony command if one failed.
- Task task = Program.HarmonyClient.TrySendKeyPressAsync(DeviceId, Command);
- bool result = task.Result; //Synchronously waiting for result
- Trace.WriteLine("ActionHarmonyCommand.DoExecute result: " + result.ToString());
+ // Send our command and wait for it async
+ await Program.HarmonyClient.TrySendKeyPressAsync(DeviceId, Command);
}
else
{
diff -r 3f1d16d233dc -r e237c2e33545 Server/SharpDisplayManager.csproj
--- a/Server/SharpDisplayManager.csproj Tue Aug 30 03:07:59 2016 +0200
+++ b/Server/SharpDisplayManager.csproj Tue Aug 30 03:45:45 2016 +0200
@@ -34,7 +34,7 @@
index.htm
false
0
- 1.0.7.0
+ 1.1.0.0
false
true
true
diff -r 3f1d16d233dc -r e237c2e33545 SharpLibEar/Action.cs
--- a/SharpLibEar/Action.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/SharpLibEar/Action.cs Tue Aug 30 03:45:45 2016 +0200
@@ -6,13 +6,14 @@
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Threading;
+using System.Threading.Tasks;
namespace SharpLib.Ear
{
[DataContract]
public abstract class Action: Object
{
- protected abstract void DoExecute();
+ protected abstract Task DoExecute();
///
/// Allows testing from generic edit dialog.
@@ -23,7 +24,7 @@
Execute();
}
- public void Execute()
+ public async Task Execute()
{
Trace.WriteLine("Action executing: " + Brief());
if (!IsValid())
@@ -32,7 +33,7 @@
return;
}
- DoExecute();
+ await DoExecute();
}
}
diff -r 3f1d16d233dc -r e237c2e33545 SharpLibEar/ActionCallback.cs
--- a/SharpLibEar/ActionCallback.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/SharpLibEar/ActionCallback.cs Tue Aug 30 03:45:45 2016 +0200
@@ -1,7 +1,7 @@
//
using System.Runtime.Serialization;
-
+using System.Threading.Tasks;
namespace SharpLib.Ear
{
@@ -17,7 +17,7 @@
iCallback = aCallback;
}
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
if (iCallback != null)
{
diff -r 3f1d16d233dc -r e237c2e33545 SharpLibEar/ActionLaunchApp.cs
--- a/SharpLibEar/ActionLaunchApp.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/SharpLibEar/ActionLaunchApp.cs Tue Aug 30 03:45:45 2016 +0200
@@ -59,7 +59,7 @@
public static extern void SwitchToThisWindow([System.Runtime.InteropServices.InAttribute()] System.IntPtr hwnd, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fUnknown);
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
//First check if the process we want to launch already exists
string procName = Path.GetFileNameWithoutExtension(File.FullPath);
diff -r 3f1d16d233dc -r e237c2e33545 SharpLibEar/ActionOpticalDriveEject.cs
--- a/SharpLibEar/ActionOpticalDriveEject.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/SharpLibEar/ActionOpticalDriveEject.cs Tue Aug 30 03:45:45 2016 +0200
@@ -47,7 +47,7 @@
return Drive.Items.Contains(Drive.CurrentItem);
}
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
DriveEject(Drive.CurrentItem);
}
diff -r 3f1d16d233dc -r e237c2e33545 SharpLibEar/ActionSleep.cs
--- a/SharpLibEar/ActionSleep.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/SharpLibEar/ActionSleep.cs Tue Aug 30 03:45:45 2016 +0200
@@ -3,7 +3,7 @@
using System.Runtime.Serialization;
using System.Threading;
-
+using System.Threading.Tasks;
namespace SharpLib.Ear
{
@@ -43,9 +43,9 @@
}
- protected override void DoExecute()
+ protected override async Task DoExecute()
{
- Thread.Sleep(TimeoutInMilliseconds);
+ await Task.Delay(TimeoutInMilliseconds);
}
}
diff -r 3f1d16d233dc -r e237c2e33545 SharpLibEar/Event.cs
--- a/SharpLibEar/Event.cs Tue Aug 30 03:07:59 2016 +0200
+++ b/SharpLibEar/Event.cs Tue Aug 30 03:45:45 2016 +0200
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.Serialization;
+using System.Threading.Tasks;
namespace SharpLib.Ear
{
@@ -48,12 +49,12 @@
}
- public void Trigger()
+ public async Task Trigger()
{
Trace.WriteLine("Event triggered: " + Name);
foreach (Action action in Actions)
{
- action.Execute();
+ await action.Execute();
}
}