System.Threading.ReaderWriterLockSlim.ExitUpgradeableReadLock C# (CSharp) Method

ExitUpgradeableReadLock() public method

public ExitUpgradeableReadLock ( ) : void
return void
		public void ExitUpgradeableReadLock ()
		{
			EnterMyLock ();
			Debug.Assert (owners > 0, "Releasing an upgradable lock, but there was no reader!");
			--owners;
			upgradable_thread = null;
			ExitAndWakeUpAppropriateWaiters ();
		}

Usage Example

 public bool CanAgentEnter(int id, Point3 pos, bool finalDestination)
 {
     _threadLock.EnterUpgradeableReadLock();
     if (!_cells.TryGetValue(pos, out var cell) || !cell.IsWalkable)
     {
         _threadLock.ExitUpgradeableReadLock();
         return(false);
     }
     if (cell.IsOccupied && cell.Occupied == id)
     {
         _threadLock.ExitUpgradeableReadLock();
         return(true);
     }
     if (finalDestination && cell.IsOccupied && cell.Occupied != id)
     {
         _threadLock.ExitUpgradeableReadLock();
         return(false);
     }
     if (cell.IsTempLocked && cell.TempLock != id)
     {
         _threadLock.ExitUpgradeableReadLock();
         return(false);
     }
     _threadLock.EnterWriteLock();
     cell.TempLock = id;
     SetCellCostInternal(cell);
     _threadLock.ExitWriteLock();
     _threadLock.ExitUpgradeableReadLock();
     return(true);
 }
All Usage Examples Of System.Threading.ReaderWriterLockSlim::ExitUpgradeableReadLock