M
Mark Rae
Hi,
I have a WinForms desktop MDI application written in C#. Following advice
from others in this forum, I prevent multiple instances of the app running
at the same time by creating / trying to create a mutex, as follows:
bool blnCreatedMutex;
objMutex = new System.Threading.Mutex(true, "zzzzzzMyCoolAppzzzzz", out
blnCreatedMutex);
if (!blnCreatedMutex)
{
MessageBox.Show("My Cool App is already running", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Stop);
this.Close();
return;
}
The app saves data files onto the file system, and I have associated these
files' extension with the app's executable. All is well - I interrogate the
args property when the app loads and try to open any files found there e.g.
foreach (string strArg in astrArgs)
{
openFile(strArg);
}
No doubt you can all guess the next question... if the app is already
running, and the user double-clicks one of its files, I want to somehow get
a message to it to open the file(s) found in the args of the second
instance, which I will then terminate.
Any assistance gratefully received.
Best,
Mark
I have a WinForms desktop MDI application written in C#. Following advice
from others in this forum, I prevent multiple instances of the app running
at the same time by creating / trying to create a mutex, as follows:
bool blnCreatedMutex;
objMutex = new System.Threading.Mutex(true, "zzzzzzMyCoolAppzzzzz", out
blnCreatedMutex);
if (!blnCreatedMutex)
{
MessageBox.Show("My Cool App is already running", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Stop);
this.Close();
return;
}
The app saves data files onto the file system, and I have associated these
files' extension with the app's executable. All is well - I interrogate the
args property when the app loads and try to open any files found there e.g.
foreach (string strArg in astrArgs)
{
openFile(strArg);
}
No doubt you can all guess the next question... if the app is already
running, and the user double-clicks one of its files, I want to somehow get
a message to it to open the file(s) found in the args of the second
instance, which I will then terminate.
Any assistance gratefully received.
Best,
Mark