K
Kovan Akrei
Hi,
I have a question on regard to Monitor.Enter(..) and Monitor.Exit(..)
I'll start with an example :
public class test{
private static Queue q = new Queue();
public method testMonitor(){
lock(q){
// do some operations on q
Monitor.Enter(this); // lock this object
}
// do some work
Monitor.Exit(this); // Release the lock on this object.
// do some more work
}
}
My question is whether Monitor.Enter (this) will survive the lock(q)
statement and "this" will still be locked for other objects to access it
until we reach and finish executing Monitor.Exit(this).
What if I call Monitor.Exit(..) in another method. Will it still work?
Regards from
Kovan Akrei
I have a question on regard to Monitor.Enter(..) and Monitor.Exit(..)
I'll start with an example :
public class test{
private static Queue q = new Queue();
public method testMonitor(){
lock(q){
// do some operations on q
Monitor.Enter(this); // lock this object
}
// do some work
Monitor.Exit(this); // Release the lock on this object.
// do some more work
}
}
My question is whether Monitor.Enter (this) will survive the lock(q)
statement and "this" will still be locked for other objects to access it
until we reach and finish executing Monitor.Exit(this).
What if I call Monitor.Exit(..) in another method. Will it still work?
Regards from
Kovan Akrei