D
Dinsdale
I have recently added a mutex to the startup of an application to stop
users from opening multiple instances. Works great except the
application no longer works on NT4. The error I get is:
The Application has generated an exception that could not be handled.
Process id = 0x12b (299), Thread id = 0x100 (256)
To test my theory, I created a small windows form app and ran it with
no problems. I added the same mutex code to it and received the same
error as noted above.
I double checked in MSDN and it claims the Mutex class is compatible
with NT4, but my experience seems to be telling me otherwise. Here is
the mutex code I'm using:
public class Form1 : System.Windows.Forms.Form
{
//....(designer code and properties here)
public static bool _bFirstInstance;
public static Mutex _mtxSingleInstance;
//....(other functionality)
[STAThread]
static void Main()
{
//This mutex is used to ensure that only one copy of the
application is running at any time.
_mtxSingleInstance = new Mutex(false,
"Local\\MY_MUTEX_SINGLE_INSTANCE", out _bFirstInstance);
if(_bFirstInstance)
{
// If _bFirstInstance is now true, we're the first instance
of the application;
// otherwise another instance is running and this will not
be called and the applicaiton
// will not start.
Application.Run(new Form1());
}
else
{
string strOutput = "There is already an instance of the
application running.\r\n"
+ "Please check the Icon Tray (right hand side of the
toolbar) for the icon.";
MessageBox.Show(strOutput);
///Else we need to bring up the running instance.
///If we cannot, we need to shut it down and start it
again.
}
}
}
Does anybody have any information on this issue? IS the Mutex class
compatible with NT4 (sp6a)? Is there an issue with my code???
Any help would be great.
Cheers!
Russ
users from opening multiple instances. Works great except the
application no longer works on NT4. The error I get is:
The Application has generated an exception that could not be handled.
Process id = 0x12b (299), Thread id = 0x100 (256)
To test my theory, I created a small windows form app and ran it with
no problems. I added the same mutex code to it and received the same
error as noted above.
I double checked in MSDN and it claims the Mutex class is compatible
with NT4, but my experience seems to be telling me otherwise. Here is
the mutex code I'm using:
public class Form1 : System.Windows.Forms.Form
{
//....(designer code and properties here)
public static bool _bFirstInstance;
public static Mutex _mtxSingleInstance;
//....(other functionality)
[STAThread]
static void Main()
{
//This mutex is used to ensure that only one copy of the
application is running at any time.
_mtxSingleInstance = new Mutex(false,
"Local\\MY_MUTEX_SINGLE_INSTANCE", out _bFirstInstance);
if(_bFirstInstance)
{
// If _bFirstInstance is now true, we're the first instance
of the application;
// otherwise another instance is running and this will not
be called and the applicaiton
// will not start.
Application.Run(new Form1());
}
else
{
string strOutput = "There is already an instance of the
application running.\r\n"
+ "Please check the Icon Tray (right hand side of the
toolbar) for the icon.";
MessageBox.Show(strOutput);
///Else we need to bring up the running instance.
///If we cannot, we need to shut it down and start it
again.
}
}
}
Does anybody have any information on this issue? IS the Mutex class
compatible with NT4 (sp6a)? Is there an issue with my code???
Any help would be great.
Cheers!
Russ