Repository navigation
Offer to restart TV Rename when the theme is changed - #1089
Conversation
A new theme only shows after a restart, so after OK in Preferences TV Rename now asks Restart now or Later. Restart now saves the settings and starts TV Rename again with the same settings folder (one off command line tasks are not repeated). - No question when the chosen theme is the one already showing - A running scan is only stopped if the user agrees, and Later is then the default - No restart while files are being copied or moved - ThemeableMessageBox can use its own wording for the Yes and No buttons
|
Have a look at |
| using Process old = Process.GetProcessById(processId); | ||
| if (!old.WaitForExit(TimeSpan.FromSeconds(60))) | ||
| { | ||
| Logger.Warn("The previous copy of TV Rename is still running after a restart"); |
There was a problem hiding this comment.
What else should we do if the old one has not closed within 60 seconds. Terminate this version?
We have 2 methods of identifying whether an old version is running no:
- This Registry /. Process Id method
- the Mutex that we use to pass parameters to already running versions: See
singleInstanceService.IsFirstInstance()
There was a problem hiding this comment.
Yes, it now closes itself. If the old copy is still running after 60 seconds, the new copy logs a warning and exits without sending it anything, leaving the old copy alone in case it is still saving.
On the two methods: the old copy closes the mutex in Main's finally, but the single instance semaphore and the port 19191 listener stay until the process ends. So the mutex can look free while IsFirstInstance() still sees the old copy, and the new one could exit with "An instance is already running". Waiting on the process covers all three. The process id is passed in an environment variable (nothing in the registry), and since ids get reused, the new copy only waits on a process that started before it.
The copy started by Restart now skips the Scan on Startup setting and the update available popup (the Update Available button still shows). The command line scans were already not passed on. If the old copy is still running after 60 seconds the new copy closes without passing it anything, and a reused process id is not mistaken for the old copy. /hide and /unattended are kept on restart, as they are how TV Rename was run rather than one off tasks.
|
Good catch: with Scan on Startup on, it would have run the scan and its actions straight after a theme change. Fixed in the latest commit. The restarted copy skips the startup scan and logs "Startup Scan not run as TV Rename has just restarted". I left RunOnStartUp() alone, as Preferences reads it for the checkbox and would save it unticked. The update popup is skipped after a restart too (the Update Available button still shows). Command line scans were already not repeated, as only /userfilepath, /createmissing, /ignoremissing and /norenamecheck are passed on. I've added /hide and /unattended, since they're how TV Rename was run rather than one off tasks. Tested with Scan on Startup and the update popup on, for a normal restart, /unattended and /hide (brought up with /focus): each first copy scanned, and each restarted copy kept its arguments, didn't scan and showed no popup. Also tested the old copy already gone (starts straight away) and one that never closes (waits 60 seconds, logs the warning, closes). |
Changing the theme needs a restart, and until now that meant closing TV Rename, finding it again and starting it back up. Now, after picking a new theme and clicking OK in Preferences, TV Rename asks "Restart now" or "Later". Restart now saves the settings and starts TV Rename again on the new theme, with the same settings folder, missing folder options and /hide or /unattended. One off command line tasks such as /scan or /doall are not repeated, and the startup scan and update popup are skipped on the restart.