Prevent Windows from going to sleep only in headless mode

This commit is contained in:
JustArchi
2017-03-07 03:47:56 +01:00
parent 758a9868ca
commit 807ef2d83a
3 changed files with 8 additions and 4 deletions

View File

@@ -31,14 +31,18 @@ namespace ArchiSteamFarm {
internal static class OS {
private static readonly PlatformID PlatformID = Environment.OSVersion.Platform;
internal static void Init() {
internal static void Init(bool headless) {
switch (PlatformID) {
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
DisableQuickEditMode();
KeepWindowsSystemActive();
if (headless) {
KeepWindowsSystemActive();
}
break;
}

View File

@@ -285,7 +285,7 @@ namespace ArchiSteamFarm {
}
ArchiWebHandler.Init();
OS.Init();
OS.Init(GlobalConfig.Headless);
WCF.Init();
WebBrowser.Init();

View File

@@ -191,7 +191,7 @@ namespace ArchiSteamFarm {
}
ArchiWebHandler.Init();
OS.Init();
OS.Init(GlobalConfig.Headless);
WebBrowser.Init();
WebBrowser = new WebBrowser(ASF.ArchiLogger);