When using the -silent option, silentUpdate.Run() gets called and only calls CheckIfCanUpdate() once. If playCount is greater than 0, CheckIfCanUpdate() merely logs this and exits with success. There is a timer set (_timer), but it isn't allowed to run as the application exits. There is no loop to recheck playCount. _timer appears to be referenced in MainForm.cs, but is not used in SilentUpdate.cs.
In windowed mode, you're running _timer which then calls OnTimedEvent which calls CheckIfCanUpdate(). This establishes the loop on WaitTime because CheckIfCanUpdate() will restart the timer if playCount is greater than 0.
In console mode, you have to keep the main thread busy doing something or the process will exit and all Timers will stop running.
My suggestion:
- Add a private boolean variable to MediaServer named
_updateComplete and set to false
- Add an
IsUpdateComplete() function to MediaServer to return _updateComplete
- Set _updateComplete in the
finally block in MediaServer.Update() at the very end.
- Add a do-while loop inside the
if (_server.IsUpdateAvailable()) block of SilentUpdate.Run() that checks !MediaServer.IsUpdateComplete() and sleeps WaitTime as an else to if (CheckIfCanUpdate())
When using the
-silentoption,silentUpdate.Run()gets called and only callsCheckIfCanUpdate()once. IfplayCountis greater than 0,CheckIfCanUpdate()merely logs this and exits with success. There is a timer set (_timer), but it isn't allowed to run as the application exits. There is no loop to recheckplayCount._timerappears to be referenced in MainForm.cs, but is not used in SilentUpdate.cs.PlexServerAutoUpdater/MainForm.cs
Line 93 in 651d6a4
In windowed mode, you're running
_timerwhich then callsOnTimedEventwhich callsCheckIfCanUpdate(). This establishes the loop onWaitTimebecauseCheckIfCanUpdate()will restart the timer ifplayCountis greater than 0.In console mode, you have to keep the main thread busy doing something or the process will exit and all Timers will stop running.
My suggestion:
_updateCompleteand set to falseIsUpdateComplete()function to MediaServer to return_updateCompletefinallyblock inMediaServer.Update()at the very end.if (_server.IsUpdateAvailable())block ofSilentUpdate.Run()that checks!MediaServer.IsUpdateComplete()and sleepsWaitTimeas anelsetoif (CheckIfCanUpdate())