One question I have is does it need to be reentrant? Does an owner of the
lock need to be able to reenter the lock multiple times? If you just need
mutal exclusion, I might do a binary Semaphore with count of 1. See my
implementation at code project:
http://www.codeproject.com/csharp/Di...gSemaphore.asp
That way, you don't care what thread owns it, just that someone does. The
owner must release it when done. Other threads will block until lock free.
You need to handle situation where an owner dies and never frees the lock.
You have that issue regardess of the primitive used. You can use some
monitor thread or some timeout on lock that handles release after some X
seconds. You could also use a Mutex. That is reentrant and needs to be
released same number of times.
--
William Stacey
"Joannes Vermorel" <fi*******@lastname.com> wrote in message
news:uD***************@TK2MSFTNGP10.phx.gbl...
I would ask first why you want to do this? To allow this kind of
granular control into a system from the outside doesn't seem like very
good design.
Can you elaborate?
The reason lies in a transparent grid computing framework that I am
working. Look at the NGrid project on http://ngrid.sf.net (not really up
to date, I will release soon). Basically I want to implement a distributed
Monitor.
Joannès