public void AcquireWriterLock() { try { #if !MONO && !PocketPC if (UseNativeSRWLock) { NativeMethods.AcquireSRWLockExclusive(ref LockSRW); } else #endif { #if UseFastResourceLock pLock.AcquireExclusive(); #else Thread.BeginCriticalRegion(); while (Interlocked.CompareExchange(ref busy, 1, 0) != 0) { Thread.Sleep(1); } while (Interlocked.CompareExchange(ref readCount, 0, 0) != 0) { Thread.Sleep(1); } #endif } } catch (Exception ex) { } }
public void AcquireWriterLock() { if (UseNativeSRWLock) { NativeMethods.AcquireSRWLockExclusive(ref LockSRW); } else { pLock?.AcquireExclusive(); } }