Example #1
0
 public static void EnterMultipleWriteLocks(SafeReaderWriterLock a, SafeReaderWriterLock b)
 {
     Validate.Begin().IsNotNull <SafeReaderWriterLock>(a, "a").IsNotNull <SafeReaderWriterLock>(b, "b").Check();
     Thread.BeginCriticalRegion();
     if (a.id == b.id)
     {
         a.EnterWriteLock();
     }
     else if (a.id < b.id)
     {
         a.EnterWriteLock();
         b.EnterWriteLock();
     }
     else
     {
         b.EnterWriteLock();
         a.EnterWriteLock();
     }
     Thread.EndCriticalRegion();
 }
Example #2
0
 internal WriteLockScope(SafeReaderWriterLock owner)
 {
     try
     {
     }
     finally
     {
         owner.EnterWriteLock();
         this.owner = owner;
     }
 }