Skip to content

Commit f741891

Browse files
committed
Support Suspend power mode change
We previously didn't support the Suspend power mode change, which meant WinNUT would be paused in the middle of execution (and with an open socket) if the system goes to sleep. Now WinNUT has the chance to close down operations and connections, which seems to at least help with errors while changing power states. It looks like WinNUT still tries to reconnect too quickly after the system resumes from sleep (before networking is fully restored?) In the interest of reducing notification spam, it may be best to have WinNUT wait a few seconds before reconnecting.
1 parent 82891d5 commit f741891

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

WinNUT_V2/WinNUT-Client/WinNUT.vb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ Public Class WinNUT
345345
Private Sub SystemEvents_PowerModeChanged(sender As Object, e As Microsoft.Win32.PowerModeChangedEventArgs)
346346
LogFile.LogTracing("PowerModeChangedEvent: " & [Enum].GetName(GetType(Microsoft.Win32.PowerModes), e.Mode), LogLvl.LOG_NOTICE, Me)
347347
Select Case e.Mode
348+
Case Microsoft.Win32.PowerModes.Suspend
349+
LogFile.LogTracing("Suspending WinNUT operations...", LogLvl.LOG_NOTICE, Me, StrLog.Item(AppResxStr.STR_MAIN_GOTOSLEEP))
350+
UPSDisconnect()
348351
Case Microsoft.Win32.PowerModes.Resume
349352
LogFile.LogTracing("Restarting WinNUT after waking up from Windows", LogLvl.LOG_NOTICE, Me, StrLog.Item(AppResxStr.STR_MAIN_EXITSLEEP))
350353
If My.Settings.NUT_AutoReconnect Then

0 commit comments

Comments
 (0)