G
Guest
I wrote some Windows application. in the Main() method of the project I use
Mutex.
I was sure that that mutex will live during all the application run time.
But it appears that the Mutex is CG after a while.
The following code is the code I'm using. I use it to make sure only one
instance of my program is running, but there are cases that the ownership is
obtained although there is already another application like this running:
[STAThread]
static void Main()
{
bool hasOwnership;
System.Threading.Mutex singelLogger = new System.Threading.Mutex(true,
"MyApplication", out hasOwnership);if( ! hasOwnership )
{
MessageBox.Show(null, "The Mutex ownership is taken.\n\n Exiting!", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Application.Run( new MyAppForm() );
}
How can that be?
Mutex.
I was sure that that mutex will live during all the application run time.
But it appears that the Mutex is CG after a while.
The following code is the code I'm using. I use it to make sure only one
instance of my program is running, but there are cases that the ownership is
obtained although there is already another application like this running:
[STAThread]
static void Main()
{
bool hasOwnership;
System.Threading.Mutex singelLogger = new System.Threading.Mutex(true,
"MyApplication", out hasOwnership);if( ! hasOwnership )
{
MessageBox.Show(null, "The Mutex ownership is taken.\n\n Exiting!", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Application.Run( new MyAppForm() );
}
How can that be?