Skip to content

SilentUpdate Only Checks Once #34

Description

@Hossy

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.

if (CheckIfCanUpdate())

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:

  1. Add a private boolean variable to MediaServer named _updateComplete and set to false
  2. Add an IsUpdateComplete() function to MediaServer to return _updateComplete
  3. Set _updateComplete in the finally block in MediaServer.Update() at the very end.
  4. 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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions