M
Martin Maat
Hi.
I want to use the same mutex in different classes (web pages in an ASP.NET
application). In global.asax.cs, the class that starts up first, I create a
Mutex like this:
static private Mutex mtxBezoeken = new Mutex(false, "bezoeken");
which compiles and executes just fine. Then in another page I want to write
to a file that may also be accessed by global.asax.cs so I want access to
the same mutex that will help me synchronize. In this other page class I
declare another Mutex object with an identical declaration. The idea is that
the system will look up any existing mutex with the id "bezoeken" and wrap
that in the Mutex object instead of creating a new system mutex. This is how
it is documented and what I am used to from Win32 programming.
However, when the second declaration is executed I get:
"System.ApplicationException: Access is denied."
It is obviously because the mutex already exists, when I change "bezoeken"
in the second declaration to a new unique id it executes fine. Of course
this would defeat the purpose of the second mutex.
I am not requesting ownership, I can't figure out what the problem is.
Martin.
I want to use the same mutex in different classes (web pages in an ASP.NET
application). In global.asax.cs, the class that starts up first, I create a
Mutex like this:
static private Mutex mtxBezoeken = new Mutex(false, "bezoeken");
which compiles and executes just fine. Then in another page I want to write
to a file that may also be accessed by global.asax.cs so I want access to
the same mutex that will help me synchronize. In this other page class I
declare another Mutex object with an identical declaration. The idea is that
the system will look up any existing mutex with the id "bezoeken" and wrap
that in the Mutex object instead of creating a new system mutex. This is how
it is documented and what I am used to from Win32 programming.
However, when the second declaration is executed I get:
"System.ApplicationException: Access is denied."
It is obviously because the mutex already exists, when I change "bezoeken"
in the second declaration to a new unique id it executes fine. Of course
this would defeat the purpose of the second mutex.
I am not requesting ownership, I can't figure out what the problem is.
Martin.