N
nano2k
Hi
Inside webservices we can access the Application object which is an
HttpApplicationState instance.
Using Application object, I defined a state variable named
"fileManager":
FileManager fm = new FileManager();
Application["fileManager"] = fm;
When executing some actions, I need exclusive access to this object.
My current code is like this:
FileManager fm = Application["fileManager"] as FileManager;
lock(fm) {
//... use fm
}
My questions:
1. Does this design effectively protects my fm object? I mean will
lock statement work?
2. Does the isolation level of the application affect this expected
behavior? I'm particularily refering to isolation level Medium
(Pooled) and High (Isolated). Do these levels require named mutexes?
Another (IMO: bad) solution would be:
Application.Lock();
try {
FileManager fm = Application["fileManager"] as FileManager;
//... use fm
}
finally {
Application.UnLock();
}
but this solution block ALL other requests until this piece of code is
executed, which is not good.
Thanks.
Inside webservices we can access the Application object which is an
HttpApplicationState instance.
Using Application object, I defined a state variable named
"fileManager":
FileManager fm = new FileManager();
Application["fileManager"] = fm;
When executing some actions, I need exclusive access to this object.
My current code is like this:
FileManager fm = Application["fileManager"] as FileManager;
lock(fm) {
//... use fm
}
My questions:
1. Does this design effectively protects my fm object? I mean will
lock statement work?
2. Does the isolation level of the application affect this expected
behavior? I'm particularily refering to isolation level Medium
(Pooled) and High (Isolated). Do these levels require named mutexes?
Another (IMO: bad) solution would be:
Application.Lock();
try {
FileManager fm = Application["fileManager"] as FileManager;
//... use fm
}
finally {
Application.UnLock();
}
but this solution block ALL other requests until this piece of code is
executed, which is not good.
Thanks.