diff --git a/src/modules/espresso/Espresso/Core/APIHelper.cs b/src/modules/espresso/Espresso/Core/APIHelper.cs index 11e7949a08..e0f23315c4 100644 --- a/src/modules/espresso/Espresso/Core/APIHelper.cs +++ b/src/modules/espresso/Espresso/Core/APIHelper.cs @@ -95,14 +95,10 @@ namespace Espresso.Shell.Core /// Status of the attempt. True if successful, false if not. public static bool SetIndefiniteKeepAwake(bool keepDisplayOn = true) { - if (keepDisplayOn) - { - return SetAwakeState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); - } - else - { - return SetAwakeState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); - } + TokenSource = new CancellationTokenSource(); + ThreadToken = TokenSource.Token; + + //Put thread for indefinite loop. } public static void SetTimedKeepAwake(long seconds, Action callback, Action failureCallback, bool keepDisplayOn = true) @@ -116,12 +112,30 @@ namespace Espresso.Shell.Core } + private static void RunIndefiniteLoop(bool keepDisplayOn = true) + { + bool success = false; + + // In case cancellation was already requested. + ThreadToken.ThrowIfCancellationRequested(); + + if (keepDisplayOn) + { + SetAwakeState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); + } + else + { + return SetAwakeState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); + } + } + private static bool RunTimedLoop(long seconds, bool keepDisplayOn = true) { bool success = false; // In case cancellation was already requested. ThreadToken.ThrowIfCancellationRequested(); + try { if (keepDisplayOn) diff --git a/src/modules/espresso/Espresso/Espresso.csproj b/src/modules/espresso/Espresso/Espresso.csproj index 6f847d6715..3669444ea8 100644 --- a/src/modules/espresso/Espresso/Espresso.csproj +++ b/src/modules/espresso/Espresso/Espresso.csproj @@ -12,6 +12,12 @@ true PowerToys.Espresso + Espresso.ico + Den Delimarsky + Den Delimarsky + Espresso + https://espresso.den.dev + Espresso.png diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj index 77aa5811fe..20f1a6e98c 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj @@ -202,6 +202,7 @@ +