Multiple Instances

Things you’d like to miss in the future...
Forum rules
When reporting a bug, please include the following information: your XYplorer version (e.g., v27.90.0047), your Windows version (e.g., Win 11), and your screen scaling percentage (e.g., 125%). We recommend adding your Windows version and screen scaling percentage to your profile or signature. This will make debugging much easier for us.
Post Reply
KenS
Posts: 44
Joined: 08 Apr 2023 07:04

Multiple Instances

Post 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.
Last edited by KenS on 09 Apr 2023 02:42, edited 1 time in total.

KenS
Posts: 44
Joined: 08 Apr 2023 07:04

Re: Multiple Instances

Post 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

admin
Site Admin
Posts: 64915
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Multiple Instances

Post 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. :)

admin
Site Admin
Posts: 64915
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Multiple Instances

Post 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.

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Multiple Instances

Post 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.

admin
Site Admin
Posts: 64915
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Multiple Instances

Post 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.

KenS
Posts: 44
Joined: 08 Apr 2023 07:04

Re: Multiple Instances

Post 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.

KenS
Posts: 44
Joined: 08 Apr 2023 07:04

Re: Multiple Instances

Post 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

KenS
Posts: 44
Joined: 08 Apr 2023 07:04

Re: Multiple Instances

Post 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

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Multiple Instances

Post 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.

KenS
Posts: 44
Joined: 08 Apr 2023 07:04

Re: Multiple Instances

Post 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

Post Reply