Keep OS system alive when CoinJoining
MODIFY
WalletWasabi.Gui/Helpers/Utils.cs
WalletWasabi.Gui/Helpers/Utils.cs
using Avalonia.Threading;
using System;
using System.IO;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace WalletWasabi.Gui.Helpers
@@ -25,5 +26,27 @@ namespace WalletWasabi.Gui.Helpers
return false;
}
+
+ [FlagsAttribute]
+ public enum EXECUTION_STATE : uint
+ {
+ ES_AWAYMODE_REQUIRED = 0x00000040,
+ ES_CONTINUOUS = 0x80000000,
+ ES_DISPLAY_REQUIRED = 0x00000002,
+ ES_SYSTEM_REQUIRED = 0x00000001
+ // Legacy flag, should not be used.
+ // ES_USER_PRESENT = 0x00000004
+ }
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
+
+ public static void KeepSystemAwake()
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED);
+ }
+ }
}
}

Keep OS system alive when CoinJoining