public static void lockSleepMode()
{
// Set new state to prevent monitor off, and thus keep the system from sleeping
fPreviousExecutionState = NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_DISPLAY_REQUIRED);
if (fPreviousExecutionState == 0)
{
#if DEBUG
throw new Exception("SetThreadExecutionState failed.");
#endif
}
}