Published v1.1.0.0.
authorStephaneLenclud
Tue, 30 Aug 2016 03:45:45 +0200
changeset 258e237c2e33545
parent 257 3f1d16d233dc
child 259 74a66917910a
Published v1.1.0.0.
EAR is now async.
Server/Actions/ActionCecActiveSource.cs
Server/Actions/ActionCecClose.cs
Server/Actions/ActionCecDevicePowerOn.cs
Server/Actions/ActionCecDeviceStandby.cs
Server/Actions/ActionCecInactiveSource.cs
Server/Actions/ActionCecOpen.cs
Server/Actions/ActionCecScan.cs
Server/Actions/ActionCecUserControlPressed.cs
Server/Actions/ActionCecUserControlReleased.cs
Server/Actions/ActionDisplayMessage.cs
Server/Actions/ActionHarmonyCommand.cs
Server/SharpDisplayManager.csproj
SharpLibEar/Action.cs
SharpLibEar/ActionCallback.cs
SharpLibEar/ActionLaunchApp.cs
SharpLibEar/ActionOpticalDriveEject.cs
SharpLibEar/ActionSleep.cs
SharpLibEar/Event.cs
     1.1 --- a/Server/Actions/ActionCecActiveSource.cs	Tue Aug 30 03:07:59 2016 +0200
     1.2 +++ b/Server/Actions/ActionCecActiveSource.cs	Tue Aug 30 03:45:45 2016 +0200
     1.3 @@ -26,7 +26,7 @@
     1.4          /// <summary>
     1.5          /// Set the defined device type as active source.
     1.6          /// </summary>
     1.7 -        protected override void DoExecute()
     1.8 +        protected override async Task DoExecute()
     1.9          {
    1.10              if (Cec.Client.Static == null)
    1.11              {
     2.1 --- a/Server/Actions/ActionCecClose.cs	Tue Aug 30 03:07:59 2016 +0200
     2.2 +++ b/Server/Actions/ActionCecClose.cs	Tue Aug 30 03:45:45 2016 +0200
     2.3 @@ -14,7 +14,7 @@
     2.4      [AttributeObject(Id = "Cec.Close", Name = "CEC Close", Description = "Close CEC connection.")]
     2.5      class ActionCecClose : SharpLib.Ear.Action
     2.6      {
     2.7 -        protected override void DoExecute()
     2.8 +        protected override async Task DoExecute()
     2.9          {
    2.10              if (Cec.Client.Static == null)
    2.11              {
     3.1 --- a/Server/Actions/ActionCecDevicePowerOn.cs	Tue Aug 30 03:07:59 2016 +0200
     3.2 +++ b/Server/Actions/ActionCecDevicePowerOn.cs	Tue Aug 30 03:45:45 2016 +0200
     3.3 @@ -27,7 +27,7 @@
     3.4          /// <summary>
     3.5          /// 
     3.6          /// </summary>
     3.7 -        protected override void DoExecute()
     3.8 +        protected override async Task DoExecute()
     3.9          {
    3.10              if (Cec.Client.Static == null)
    3.11              {
     4.1 --- a/Server/Actions/ActionCecDeviceStandby.cs	Tue Aug 30 03:07:59 2016 +0200
     4.2 +++ b/Server/Actions/ActionCecDeviceStandby.cs	Tue Aug 30 03:45:45 2016 +0200
     4.3 @@ -27,7 +27,7 @@
     4.4          /// <summary>
     4.5          /// 
     4.6          /// </summary>
     4.7 -        protected override void DoExecute()
     4.8 +        protected override async Task DoExecute()
     4.9          {
    4.10              if (Cec.Client.Static == null)
    4.11              {
     5.1 --- a/Server/Actions/ActionCecInactiveSource.cs	Tue Aug 30 03:07:59 2016 +0200
     5.2 +++ b/Server/Actions/ActionCecInactiveSource.cs	Tue Aug 30 03:45:45 2016 +0200
     5.3 @@ -14,7 +14,7 @@
     5.4      [AttributeObject(Id = "Cec.InactiveSource", Name = "CEC Inactive Source", Description = "Set this CEC device as inactive source.")]
     5.5      class ActionCecInactiveSource : SharpLib.Ear.Action
     5.6      {
     5.7 -        protected override void DoExecute()
     5.8 +        protected override async Task DoExecute()
     5.9          {
    5.10              if (Cec.Client.Static == null)
    5.11              {
     6.1 --- a/Server/Actions/ActionCecOpen.cs	Tue Aug 30 03:07:59 2016 +0200
     6.2 +++ b/Server/Actions/ActionCecOpen.cs	Tue Aug 30 03:45:45 2016 +0200
     6.3 @@ -14,7 +14,7 @@
     6.4      [AttributeObject(Id = "Cec.Open", Name = "CEC Open", Description = "Open CEC connection.")]
     6.5      class ActionCecOpen : SharpLib.Ear.Action
     6.6      {
     6.7 -        protected override void DoExecute()
     6.8 +        protected override async Task DoExecute()
     6.9          {
    6.10              if (Cec.Client.Static == null)
    6.11              {
     7.1 --- a/Server/Actions/ActionCecScan.cs	Tue Aug 30 03:07:59 2016 +0200
     7.2 +++ b/Server/Actions/ActionCecScan.cs	Tue Aug 30 03:45:45 2016 +0200
     7.3 @@ -15,7 +15,7 @@
     7.4      [AttributeObject(Id = "Cec.Scan", Name = "CEC Scan", Description = "Scan devices on your CEC HDMI network.")]
     7.5      class ActionCecScan : SharpLib.Ear.Action
     7.6      {
     7.7 -        protected override void DoExecute()
     7.8 +        protected override async Task DoExecute()
     7.9          {
    7.10              if (Cec.Client.Static == null)
    7.11              {
     8.1 --- a/Server/Actions/ActionCecUserControlPressed.cs	Tue Aug 30 03:07:59 2016 +0200
     8.2 +++ b/Server/Actions/ActionCecUserControlPressed.cs	Tue Aug 30 03:45:45 2016 +0200
     8.3 @@ -57,7 +57,7 @@
     8.4          /// <summary>
     8.5          /// 
     8.6          /// </summary>
     8.7 -        protected override void DoExecute()
     8.8 +        protected override async Task DoExecute()
     8.9          {
    8.10              if (Cec.Client.Static == null)
    8.11              {
     9.1 --- a/Server/Actions/ActionCecUserControlReleased.cs	Tue Aug 30 03:07:59 2016 +0200
     9.2 +++ b/Server/Actions/ActionCecUserControlReleased.cs	Tue Aug 30 03:45:45 2016 +0200
     9.3 @@ -49,7 +49,7 @@
     9.4          /// <summary>
     9.5          /// 
     9.6          /// </summary>
     9.7 -        protected override void DoExecute()
     9.8 +        protected override async Task DoExecute()
     9.9          {
    9.10              if (Cec.Client.Static == null)
    9.11              {
    10.1 --- a/Server/Actions/ActionDisplayMessage.cs	Tue Aug 30 03:07:59 2016 +0200
    10.2 +++ b/Server/Actions/ActionDisplayMessage.cs	Tue Aug 30 03:45:45 2016 +0200
    10.3 @@ -66,7 +66,7 @@
    10.4          /// <summary>
    10.5          /// 
    10.6          /// </summary>
    10.7 -        protected override void DoExecute()
    10.8 +        protected override async Task DoExecute()
    10.9          {
   10.10              StartMessageClient();
   10.11          }
    11.1 --- a/Server/Actions/ActionHarmonyCommand.cs	Tue Aug 30 03:07:59 2016 +0200
    11.2 +++ b/Server/Actions/ActionHarmonyCommand.cs	Tue Aug 30 03:45:45 2016 +0200
    11.3 @@ -69,17 +69,12 @@
    11.4          /// <summary>
    11.5          /// 
    11.6          /// </summary>
    11.7 -        protected override void DoExecute()
    11.8 +        protected override async Task DoExecute()
    11.9          {
   11.10 -            //Fire and forget our command
   11.11 -            //TODO: check if the harmony client connection is opened
   11.12              if (Program.HarmonyClient!=null)
   11.13              {
   11.14 -                // Wait synchronously for now until we figure out how we could do async stuff in EAR.
   11.15 -                // TODO: Have an abort option in EAR. For instance we don't want to keep sending Harmony command if one failed.
   11.16 -                Task<bool> task = Program.HarmonyClient.TrySendKeyPressAsync(DeviceId, Command);
   11.17 -                bool result = task.Result; //Synchronously waiting for result
   11.18 -                Trace.WriteLine("ActionHarmonyCommand.DoExecute result: " + result.ToString());
   11.19 +                // Send our command and wait for it async
   11.20 +                await Program.HarmonyClient.TrySendKeyPressAsync(DeviceId, Command);               
   11.21              }
   11.22              else
   11.23              {
    12.1 --- a/Server/SharpDisplayManager.csproj	Tue Aug 30 03:07:59 2016 +0200
    12.2 +++ b/Server/SharpDisplayManager.csproj	Tue Aug 30 03:45:45 2016 +0200
    12.3 @@ -34,7 +34,7 @@
    12.4      <WebPage>index.htm</WebPage>
    12.5      <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
    12.6      <ApplicationRevision>0</ApplicationRevision>
    12.7 -    <ApplicationVersion>1.0.7.0</ApplicationVersion>
    12.8 +    <ApplicationVersion>1.1.0.0</ApplicationVersion>
    12.9      <UseApplicationTrust>false</UseApplicationTrust>
   12.10      <CreateDesktopShortcut>true</CreateDesktopShortcut>
   12.11      <PublishWizardCompleted>true</PublishWizardCompleted>
    13.1 --- a/SharpLibEar/Action.cs	Tue Aug 30 03:07:59 2016 +0200
    13.2 +++ b/SharpLibEar/Action.cs	Tue Aug 30 03:45:45 2016 +0200
    13.3 @@ -6,13 +6,14 @@
    13.4  using System.Diagnostics;
    13.5  using System.Runtime.Serialization;
    13.6  using System.Threading;
    13.7 +using System.Threading.Tasks;
    13.8  
    13.9  namespace SharpLib.Ear
   13.10  {
   13.11      [DataContract]
   13.12      public abstract class Action: Object
   13.13      {
   13.14 -        protected abstract void DoExecute();
   13.15 +        protected abstract Task DoExecute();
   13.16  
   13.17          /// <summary>
   13.18          /// Allows testing from generic edit dialog.
   13.19 @@ -23,7 +24,7 @@
   13.20              Execute();
   13.21          }
   13.22  
   13.23 -        public void Execute()
   13.24 +        public async Task Execute()
   13.25          {
   13.26              Trace.WriteLine("Action executing: " + Brief());
   13.27              if (!IsValid())
   13.28 @@ -32,7 +33,7 @@
   13.29                  return;
   13.30              }
   13.31              
   13.32 -            DoExecute();
   13.33 +            await DoExecute();
   13.34          }
   13.35  
   13.36      }
    14.1 --- a/SharpLibEar/ActionCallback.cs	Tue Aug 30 03:07:59 2016 +0200
    14.2 +++ b/SharpLibEar/ActionCallback.cs	Tue Aug 30 03:45:45 2016 +0200
    14.3 @@ -1,7 +1,7 @@
    14.4  //
    14.5  
    14.6  using System.Runtime.Serialization;
    14.7 -
    14.8 +using System.Threading.Tasks;
    14.9  
   14.10  namespace SharpLib.Ear
   14.11  {
   14.12 @@ -17,7 +17,7 @@
   14.13              iCallback = aCallback;
   14.14          }
   14.15  
   14.16 -        protected override void DoExecute()
   14.17 +        protected override async Task DoExecute()
   14.18          {
   14.19              if (iCallback != null)
   14.20              {
    15.1 --- a/SharpLibEar/ActionLaunchApp.cs	Tue Aug 30 03:07:59 2016 +0200
    15.2 +++ b/SharpLibEar/ActionLaunchApp.cs	Tue Aug 30 03:45:45 2016 +0200
    15.3 @@ -59,7 +59,7 @@
    15.4          public static extern void SwitchToThisWindow([System.Runtime.InteropServices.InAttribute()] System.IntPtr hwnd, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fUnknown);
    15.5  
    15.6  
    15.7 -        protected override void DoExecute()
    15.8 +        protected override async Task DoExecute()
    15.9          {
   15.10              //First check if the process we want to launch already exists
   15.11              string procName = Path.GetFileNameWithoutExtension(File.FullPath);
    16.1 --- a/SharpLibEar/ActionOpticalDriveEject.cs	Tue Aug 30 03:07:59 2016 +0200
    16.2 +++ b/SharpLibEar/ActionOpticalDriveEject.cs	Tue Aug 30 03:45:45 2016 +0200
    16.3 @@ -47,7 +47,7 @@
    16.4              return Drive.Items.Contains(Drive.CurrentItem);
    16.5          }
    16.6  
    16.7 -        protected override void DoExecute()
    16.8 +        protected override async Task DoExecute()
    16.9          {
   16.10              DriveEject(Drive.CurrentItem);
   16.11          }
    17.1 --- a/SharpLibEar/ActionSleep.cs	Tue Aug 30 03:07:59 2016 +0200
    17.2 +++ b/SharpLibEar/ActionSleep.cs	Tue Aug 30 03:45:45 2016 +0200
    17.3 @@ -3,7 +3,7 @@
    17.4  
    17.5  using System.Runtime.Serialization;
    17.6  using System.Threading;
    17.7 -
    17.8 +using System.Threading.Tasks;
    17.9  
   17.10  namespace SharpLib.Ear
   17.11  {
   17.12 @@ -43,9 +43,9 @@
   17.13          }
   17.14  
   17.15  
   17.16 -        protected override void DoExecute()
   17.17 +        protected override async Task DoExecute()
   17.18          {
   17.19 -            Thread.Sleep(TimeoutInMilliseconds);
   17.20 +            await Task.Delay(TimeoutInMilliseconds);
   17.21          }
   17.22  
   17.23      }
    18.1 --- a/SharpLibEar/Event.cs	Tue Aug 30 03:07:59 2016 +0200
    18.2 +++ b/SharpLibEar/Event.cs	Tue Aug 30 03:45:45 2016 +0200
    18.3 @@ -5,6 +5,7 @@
    18.4  using System.Collections.Generic;
    18.5  using System.Diagnostics;
    18.6  using System.Runtime.Serialization;
    18.7 +using System.Threading.Tasks;
    18.8  
    18.9  namespace SharpLib.Ear
   18.10  {
   18.11 @@ -48,12 +49,12 @@
   18.12          }
   18.13  
   18.14  
   18.15 -        public void Trigger()
   18.16 +        public async Task Trigger()
   18.17          {
   18.18              Trace.WriteLine("Event triggered: " + Name);
   18.19              foreach (Action action in Actions)
   18.20              {
   18.21 -                action.Execute();
   18.22 +                await action.Execute();
   18.23              }
   18.24          }
   18.25