Page 1 of 1
Multiple Instances
Posted: 09 Apr 2023 02:30
by KenS
No big deal and I doubt it would even be worth fixing, but for your info, "Startup & Exit | Allow multiple instances" does not seem to support multiple desktops. If this field is cleared I cannot start another instance on the same desktop, but can on another desktop.
Re: Multiple Instances
Posted: 09 Apr 2023 02:40
by KenS
admin wrote: ↑08 Apr 2023 12:30If they are all reading and writing the same configuration files, it has to be understood that the last instance that writes those files will "win" and overwrite any changes by previous instances.
So if a user makes a substantial number of changes to the settings, then exits (and saves) and does not notice there is another copy of XY running (and using the same settings) then when that copy closes (or even when Windows closes), all those changes made by the user are lost, without warning?
Would it be possible for the copy saving changes to broadcast a message to copies and if one is using the same settings, to either reload settings, or to issue a warning, either then or when that copy later closes?
Ken
Re: Multiple Instances
Posted: 09 Apr 2023 09:17
by admin
substantial number of changes ... what kind of changes are these? You don't want to spread all changes across the instances (virtually everything in XY is stored and remembered across sessions). Then they all would end up identical twins.

Re: Multiple Instances
Posted: 09 Apr 2023 11:42
by admin
KenS wrote: ↑09 Apr 2023 02:30
No big deal and I doubt it would even be worth fixing, but for your info, "Startup & Exit | Allow multiple instances" does not seem to support multiple desktops. If this field is cleared I cannot start another instance on the same desktop, but can on another desktop.
Interesting. But can't do much about it.
Re: Multiple Instances
Posted: 09 Apr 2023 12:27
by klownboy
Wouldn't you be better off starting the other instance(s) on other desktops with a different XYplorer.ini file (e.g., /ini=myini) especially if the instances were different in some specific ways? You should look at "Command Line Switches" in the Help file.
Re: Multiple Instances
Posted: 09 Apr 2023 15:57
by admin
KenS wrote: ↑09 Apr 2023 02:40
Would it be possible for the copy saving changes to broadcast a message to copies and if one is using the same settings, to either reload settings, or to issue a warning, either then or when that copy later closes?
I will definitely consider this. Probably I'll go with the
warning before saving, sth like "[filename] has been modified by another process. Should I overwrite it anyway?" ... I'm open to suggestions in logic, wording, and correct English.
Note that this has to been done for each data file (there are about a dozen), so there will be many warnings.
Re: Multiple Instances
Posted: 11 Apr 2023 12:15
by KenS
admin wrote: ↑09 Apr 2023 11:42
Interesting. But can't do much about it.
I agree it is not worth doing anything, but it is possible to know if another instance is running on another desktop ... mutex is one way I think, can't remember for sure, or broadcast a message.
Re: Multiple Instances
Posted: 11 Apr 2023 12:35
by KenS
admin wrote: ↑09 Apr 2023 15:57
I will definitely consider this. Probably I'll go with the
warning before saving, sth like "[filename] has been modified by another process. Should I overwrite it anyway?" ... I'm open to suggestions in logic, wording, and correct English.
Note that this has to been done for each data file (there are about a dozen), so there will be many warnings.
Confused, I got the impression ("identical twins") that you didn't think this was a problem.
Ok, I am obviously new here ... some thoughts ...
If XY instance makes changes and saves them, it notifies all other instances, informing what ini file it is using and a save has been done. Any other instance, if using the same ini file, prompts user:
(a) save now and overwrite
(b) exit without saving
(c) reload new settings
Need to be careful with (a) not to get into an infinite loop
Re: Multiple Instances
Posted: 11 Apr 2023 12:38
by KenS
klownboy wrote: ↑09 Apr 2023 12:27
Wouldn't you be better off starting the other instance(s) on other desktops with a different XYplorer.ini file (e.g., /ini=myini) especially if the instances were different in some specific ways? You should look at "Command Line Switches" in the Help file.
Yes, I have been thinking of running XY with different ini files, one for copying files from development to live, another for scanning backups, etc, but here I am thinking about two instances using the same settings.
Ken
Re: Multiple Instances
Posted: 11 Apr 2023 12:44
by klownboy
You may have some situations where the use of XY's
get("instance") may be of some help in scripting. This will determine if there are 2 instances of XY running and close the current instance
if the current instance is the 2nd instance. For example:
Code: Select all
if(runret("""cmd"" /c ""tasklist | find /I /C ""XYplorer.exe""""") >= 2) {
if(get("instance") == '2') {
exit "n"; end(1);}
else {
$PID = trim(gettoken(runret("""cmd"" /c ""for /F ""TOKENS=1,2,*"" %a in ('tasklist /nh /FI ""IMAGENAME eq XYplorer.exe""') do set MyPID=%b"""),-1, "=","t",2)," <crlf>", "LR");
run "cmd /c taskkill /PID $PID",,0,0; end(1);}
}
else {
if(exists(<curitem>) == '2') {bla, bla, bla...
Edit: I had to run out, but the first else statement should kill a 2nd instance of XY if you are not currently in the 2nd instance (e.g., you are in the first instance and a 2nd instance exists). I don't know how or if this would work for multiple desktops though.
Re: Multiple Instances
Posted: 12 Apr 2023 10:12
by KenS
klownboy wrote: ↑11 Apr 2023 12:44
You may have some situations where the use of XY's
get("instance") may be of some help in scripting. ... I don't know how or if this would work for multiple desktops though.
Thanks, will look at it ... I am not sure about multiple virtual desktops, at least the "real" ones, had a bit of a look and they seem more "isolated" then I had thought.
Ken