예제 #1
0
        private static void KeepWindowsSystemActive()
        {
            // This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running
            // More info: https://msdn.microsoft.com/library/windows/desktop/aa373208(v=vs.85).aspx
            NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.AwakeExecutionState);

            // SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.Error) in our case
            if (result == NativeMethods.EExecutionState.Error)
            {
            }
        }
예제 #2
0
        private static void KeepWindowsSystemActive()
        {
            // This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running
            // If user wishes to enter sleep mode, then he should use ShutdownOnFarmingFinished or manage ASF process with third-party tool or script
            // More info: https://msdn.microsoft.com/library/windows/desktop/aa373208(v=vs.85).aspx
            NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.EExecutionState.AwayModeRequired | NativeMethods.EExecutionState.Continuous | NativeMethods.EExecutionState.SystemRequired);

            // SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.Error) in our case
            if (result == NativeMethods.EExecutionState.Error)
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningFailedWithError, result));
            }
        }
예제 #3
0
        private static void KeepWindowsSystemActive()
        {
            // This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running
            // If user wishes to enter sleep mode, then he should use ShutdownOnFarmingFinished or manage ASF process with third-party tool or script
            // More info: https://msdn.microsoft.com/library/windows/desktop/aa373208(v=vs.85).aspx
            NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.AwakeExecutionState);

            // SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.Error) in our case
            if (result == NativeMethods.EExecutionState.Error)
            {
                Logger.Log($"Failed due to error: {result}");
            }
        }
예제 #4
0
        private static void WindowsKeepSystemActive()
        {
            if (!IsWindows)
            {
                return;
            }

            // This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running
            // If user wishes to enter sleep mode, then he should use ShutdownOnFarmingFinished or manage ASF process with third-party tool or script
            // See https://docs.microsoft.com/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate for more details
            NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.AwakeExecutionState);

            // SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.None) in our case
            if (result == NativeMethods.EExecutionState.None)
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningFailedWithError, result));
            }
        }