Do you know what means "A thread can block only on the first, or outermost lock."?

I quote the related context below as well.

--------------------
Nested Locking
A thread can repeatedly lock the same object, either via multiple calls to Monitor.Enter, or via nested lock statements. The object is then unlocked when a corresponding number of Monitor.Exit statements have executed, or the outermost lock statement has exited. This allows for the most natural semantics when one method calls another as follows:

A thread can block only on the first, or outermost lock.
--------------------

thanks in advance,
George

03-22-2008

Wraithan

It means that you have to unlock as many times as you lock in order for the resource to be unlocked. That way if you lock something, lock it again, then unlock it once (because that portion of the code is done with the variable but the calling portion of the code feels the need to lock it) it is still locked and you must unlock it again.

03-23-2008

George2

Thanks Wraithan,

Question answered.

Quote:

Originally Posted by Wraithan

It means that you have to unlock as many times as you lock in order for the resource to be unlocked. That way if you lock something, lock it again, then unlock it once (because that portion of the code is done with the variable but the calling portion of the code feels the need to lock it) it is still locked and you must unlock it again.