How could I allow a single instance application started from the same directory but several instances from different directories of the same executable ?
More clearly,
I want MyProgram.Exe<instance 1> to be run mono instance from "C:\Directory1"
I want MyProgram.Exe<instance 2> to be run mono instance from "C:\Directory2"
And MyProgram.Exe<instance 1> and MyProgram.Exe<instance 2> can be run at the same time.
What I'm doing at this time is using Mutex, but I don't know how to achieve this :
public partial class App : Application
{
private static Mutex _mutex = null;
// Application GUID
private string _applicationGUID = "4hfd130b-1eh6-4979-bbqc-08g16478c36f";
public App()
{
bool isNewInstance;
_mutex = new Mutex(true, _applicationGUID, out isNewInstance);
if (!isNewInstance)
{
MessageBox.Show("An application is already running. Closing...", "MyProgram", MessageBoxButton.OK, MessageBoxImage.Exclamation);
Current.Shutdown();
}
else
{
// Other stuff ...
}
}
}
Your help will be appreciated.
You might be able to use
Assembly.Location(or the exe path in general) as the named mutex, with or without your Id.or completely overkill