Ejemplo n.º 1
0
 public BatchLock(IBatchLockable o, Action fireatend)
 {
     _o         = o;
     _oldBatch  = o.BatchLevel++;
     _startSeq  = o.ChangeSeq;
     _fireatend = fireatend;
 }
Ejemplo n.º 2
0
        // If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // Dispose managed resources, in this case effectively a lock
                    // also check to be sure we're not undoing locks in the wrong order
                    if (--_o.BatchLevel != _oldBatch)
                    {
                        throw new Exception("Programmer error: attempt made to unwind batch editing locks on " + _o.Name + " in wrong order");
                    }
                    if (_o.BatchLevel == 0 && _startSeq != _o.ChangeSeq)
                    {
                        _fireatend();
                    }
                    _o = null;
                }
                // Dispose unmanaged resources--but there are none for this class, so no code here.

                _disposed = true;
            }
        }