No thats not suffecient. I am writing a test application and I need to
syncronize my database access. I need one funciton to execute at the rate
around 100 times a seconds. This funcation will be called at the same time
from multiple threads. A second thread that is called once every second
needs to lock so the other function does not get called while its running.
In SQL you would do this by creating a shared lock on the first function
then a exclusive lock on the second. This allows many threads to have
shared access but once a thread has an exclusive lock any shared locks will
wait.
It sounds like the ReaderWriterLoc k is what I will need. I didn't even no
that class existed.
"William Stacey [MVP]" <wi************ @gmail.com> wrote in message
news:eN******** ******@tk2msftn gp13.phx.gbl...
Hi Bob. That is actually what a Monitor if for. Only one thead at a time
can own the lock on the Monitor object and any others will Q waiting for
it
to free in ~FIFO order. Each thread must lock on the same object for this
to work.
--
William Stacey [MVP]
"Bob Bins" <ms****@hotmail .com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
| Is there a way to create a shared lock using the Monitor class or any
other
| synchronization class in .NET?
|
| So I have one resource that may have multiple threads using it at once
but
a
| second thread that when called must have exclusive access and cause the
| other threads to wait.
|
| I can't figure out how to do this with .Net.
|
| Thanks.
|
|