Update loops

This commit is contained in:
Den Delimarsky 2021-05-11 14:42:42 -07:00
parent b22e409d91
commit 3196de2e29
No known key found for this signature in database
GPG key ID: E1BE1355085F0BCF
3 changed files with 29 additions and 8 deletions

View file

@ -95,14 +95,10 @@ namespace Espresso.Shell.Core
/// <returns>Status of the attempt. True if successful, false if not.</returns>
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<bool> 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)

View file

@ -12,6 +12,12 @@
<!--Per documentation: https://docs.microsoft.com/dotnet/core/compatibility/windows-forms/5.0/automatically-infer-winexe-output-type#outputtype-set-to-winexe-for-wpf-and-winforms-apps -->
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
<AssemblyName>PowerToys.Espresso</AssemblyName>
<ApplicationIcon>Espresso.ico</ApplicationIcon>
<Company>Den Delimarsky</Company>
<Authors>Den Delimarsky</Authors>
<Product>Espresso</Product>
<PackageProjectUrl>https://espresso.den.dev</PackageProjectUrl>
<PackageIcon>Espresso.png</PackageIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

View file

@ -202,6 +202,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Assets\FluentIcons\FluentIconsColorPicker.png" />
<Content Include="Assets\FluentIcons\FluentIconsEspresso.png" />
<Content Include="Assets\FluentIcons\FluentIconsFancyZones.png" />
<Content Include="Assets\FluentIcons\FluentIconsFileExplorerPreview.png" />
<Content Include="Assets\FluentIcons\FluentIconsImageResizer.png" />