i've got a Set and a Get in a property. I want to allow multiple threads to do Get anytime they wish to, however if any thread tries to do Set, all threads must not be able to Get/Set until the Set is complete.
what i tried is this (lock is a Mutex):
the problem is that this is pretty inefficient because each request to Get will steal the Mutex and prevent other Gets until the stolen Mutex is Released.Code:Public Shared Property someproperty() As Boolean Get lock.WaitOne() lock.ReleaseMutex() Return VAR_propvalue End Get Set(ByVal value As Boolean) lock.WaitOne() VAR_propvalue = value lock.ReleaseMutex() End Set End Property
Is there anyway to just check if a Mutex is released instead of using WaitOne because WaitOne checks and gains control of the Mutex which is not what i want




Reply With Quote