mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Prevent multiple auto-applies when windows calls power event too often
This commit is contained in:
@@ -28,6 +28,7 @@ namespace GHelper
|
|||||||
|
|
||||||
private static long lastAuto;
|
private static long lastAuto;
|
||||||
private static long lastTheme;
|
private static long lastTheme;
|
||||||
|
private static PowerLineStatus isPlugged = PowerLineStatus.Unknown;
|
||||||
|
|
||||||
// The main entry point for the application
|
// The main entry point for the application
|
||||||
public static void Main()
|
public static void Main()
|
||||||
@@ -121,7 +122,7 @@ namespace GHelper
|
|||||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
|
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
|
||||||
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
|
||||||
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||||
|
|
||||||
Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
|
Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
|
||||||
|
|
||||||
@@ -140,6 +141,8 @@ namespace GHelper
|
|||||||
|
|
||||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
|
||||||
|
|
||||||
Logger.WriteLine("Windows - Power Mode Changed");
|
Logger.WriteLine("Windows - Power Mode Changed");
|
||||||
SetAutoModes(true);
|
SetAutoModes(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user