Example #1
0
 private void Locker_LockStatusChanged(object sender, GenericEventArgs <LockStatus> e)
 {
     if (_idle && storedStatus != CurrentStatus)
     {
         storedStatus = CurrentStatus;
         LockStatusChanged?.Invoke(this, new GenericEventArgs <LockStatus>(CurrentStatus));
     }
 }
Example #2
0
        /// <summary>
        /// Used to request an unlock.
        /// </summary>
        /// <param name="token">The token used when the lock was requested.</param>
        public void RequestUnlock(object token)
        {
            bool fireEvent = _tokens.Remove(token) && _tokens.Any() == false;

            if (fireEvent)
            {
                LockStatusChanged?.Invoke(this, new GenericEventArgs <LockStatus>(LockStatus.Free));
            }
        }
Example #3
0
        void OperationWrapper(Action callback)
        {
            _idle = false;
            var preOperationStatus = CurrentStatus;

            callback();
            if (CurrentStatus != preOperationStatus)
            {
                LockStatusChanged?.Invoke(this, new GenericEventArgs <LockStatus>(CurrentStatus));
            }
            _idle = true;
        }
Example #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _tokens.Clear();
             LockStatusChanged?.Invoke(this, new GenericEventArgs <LockStatus>(LockStatus.Free));
             LockStatusChanged = null;
         }
         _disposed = true;
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             Component = null;
             DefaultLocker.Dispose();
             LockStatusChanged?.Invoke(this, new GenericEventArgs <LockStatus>(LockStatus.Free));
             LockStatusChanged = null;
         }
         _disposed = true;
     }
 }
Example #6
0
        /// <summary>
        /// Used to request a lock.
        /// </summary>
        /// <param name="token">The lock token.</param>
        public void RequestLock(object token)
        {
            if (token == null)
            {
                return;
            }

            bool fireEvent = _tokens.Count == 0;

            if (_tokens.Contains(token) == false)
            {
                _tokens.Add(token);
            }

            if (fireEvent)
            {
                LockStatusChanged?.Invoke(this, new GenericEventArgs <LockStatus>(LockStatus.Locked));
            }
        }
 private void Component_LockStatusChanged(object sender, GenericEventArgs <LockStatus> e) =>
 LockStatusChanged?.Invoke(sender, e);
 public void FireLockStatusChanged(LockStatus status) =>
 LockStatusChanged?.Invoke(this, new GenericEventArgs <LockStatus>(status));