fCraft.BlockDB.GetWriteLock C# (CSharp) Method

GetWriteLock() public method

Acquires and returns an exclusive (write) lock for this BlockDB. Disposing the object returned by this method releases the lock.
public GetWriteLock ( ) : IDisposable
return IDisposable
        public IDisposable GetWriteLock()
        {
            return locker.WriteLock();
        }

Usage Example

Example #1
0
 public World ChangeMap([NotNull] Map newMap)
 {
     if (newMap == null)
     {
         throw new ArgumentNullException("newMap");
     }
     lock ( SyncRoot ) {
         World newWorld = new World(Name)
         {
             AccessSecurity = (SecurityController)AccessSecurity.Clone(),
             BuildSecurity  = (SecurityController)BuildSecurity.Clone(),
             IsHidden       = IsHidden,
             BlockDB        = BlockDB,
             lastBackup     = lastBackup,
             BackupInterval = BackupInterval,
             IsLocked       = IsLocked,
             LockedBy       = LockedBy,
             UnlockedBy     = UnlockedBy,
             LockedOn       = LockedOn,
             UnlockedOn     = UnlockedOn,
             LoadedBy       = LoadedBy,
             LoadedOn       = LoadedOn,
             MapChangedBy   = MapChangedBy,
             MapChangedOn   = DateTime.UtcNow,
             FogColor       = FogColor,
             CloudColor     = CloudColor,
             SkyColor       = SkyColor,
             EdgeLevel      = EdgeLevel,
             EdgeBlock      = EdgeBlock
         };
         newMap.World     = newWorld;
         newWorld.Map     = newMap;
         newWorld.Preload = preload;
         WorldManager.ReplaceWorld(this, newWorld);
         using (BlockDB.GetWriteLock()) {
             BlockDB.Clear();
             BlockDB.World = newWorld;
         }
         foreach (Player player in Players)
         {
             player.JoinWorld(newWorld, WorldChangeReason.Rejoin);
         }
         return(newWorld);
     }
 }
All Usage Examples Of fCraft.BlockDB::GetWriteLock