public bool ChangeDelay(DispatcherItemId id, long delay)
 {
     if (!IsDelayValid(delay))
     {
         return false;
     }
     return ChangePropertyById(id, item => item.Delay = delay);
 }
 public bool ChangeAction(DispatcherItemId id, Action action)
 {
     if (!IsActionValid(action))
     {
         return false;
     }
     return ChangePropertyById(id, item => item.Action = action);
 }
 public bool Add(DispatcherItemId id, Action action, long delay, bool isActive = true)
 {
     if (!IsActionValid(action) || !IsDelayValid(delay))
     {
         return false;
     }
     return _items.TryAdd(id, new DispatcherItem(action, delay, isActive));
 }
 public bool Resume(DispatcherItemId id)
 {
     return ChangePropertyById(id, item => item.IsActive = true);
 }
 public bool Remove(DispatcherItemId id)
 {
     DispatcherItem item;
     return _items.TryRemove(id, out item);
 }
 public bool Pause(DispatcherItemId id)
 {
     return ChangePropertyById(id, item => item.IsActive = false);
 }
 private bool ChangePropertyById(DispatcherItemId id, Action<DispatcherItem> changeFunc)
 {
     DispatcherItem item;
     if (_items.TryGetValue(id, out item))
     {
         changeFunc.Invoke(item);
         return true;
     }
     return false;
 }