mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[Hotfix] PowerToys Awake - fixing CPU usage (#11978)
* Change how background threads operate This should reduce CPU usage. * Well there is just no need for the console here * Need to keep the full name sanitized
This commit is contained in:
parent
a90c738c10
commit
4c323ab71a
@ -184,13 +184,10 @@ namespace Awake.Core
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
_log.Info($"Initiated indefinite keep awake in background thread: {GetCurrentThreadId()}. Screen on: {keepDisplayOn}");
|
_log.Info($"Initiated indefinite keep awake in background thread: {GetCurrentThreadId()}. Screen on: {keepDisplayOn}");
|
||||||
while (true)
|
|
||||||
{
|
WaitHandle.WaitAny(new[] { _threadToken.WaitHandle });
|
||||||
if (_threadToken.IsCancellationRequested)
|
|
||||||
{
|
return success;
|
||||||
_threadToken.ThrowIfCancellationRequested();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,7 @@ namespace Awake
|
|||||||
{
|
{
|
||||||
private static Mutex? _mutex = null;
|
private static Mutex? _mutex = null;
|
||||||
private const string AppName = "Awake";
|
private const string AppName = "Awake";
|
||||||
|
private const string FullAppName = "PowerToys " + AppName;
|
||||||
private static FileSystemWatcher? _watcher = null;
|
private static FileSystemWatcher? _watcher = null;
|
||||||
private static SettingsUtils? _settingsUtils = null;
|
private static SettingsUtils? _settingsUtils = null;
|
||||||
|
|
||||||
@ -127,7 +128,6 @@ namespace Awake
|
|||||||
private static void ForceExit(string message, int exitCode)
|
private static void ForceExit(string message, int exitCode)
|
||||||
{
|
{
|
||||||
_log.Info(message);
|
_log.Info(message);
|
||||||
Console.ReadKey();
|
|
||||||
Environment.Exit(exitCode);
|
Environment.Exit(exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ namespace Awake
|
|||||||
.Select(e => e.EventArgs)
|
.Select(e => e.EventArgs)
|
||||||
.Subscribe(HandleAwakeConfigChange);
|
.Subscribe(HandleAwakeConfigChange);
|
||||||
|
|
||||||
TrayHelper.SetTray(AppName, new AwakeSettings());
|
TrayHelper.SetTray(FullAppName, new AwakeSettings());
|
||||||
|
|
||||||
// Initially the file might not be updated, so we need to start processing
|
// Initially the file might not be updated, so we need to start processing
|
||||||
// settings right away.
|
// settings right away.
|
||||||
|
Loading…
Reference in New Issue
Block a user