public void AddItem(DictionaryItem item) { _locker.WaitOne(); lock (_locker) { try { DictionaryItem realItem = item.GetRealItem(); if (realItem == null) { return; } Items.Remove(realItem); if (Items.Count == _maxItemsCount) { Items.RemoveAt(_maxItemsCount - 1); } Items.Insert(0, realItem); WriteData(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } }
public bool HasItem(DictionaryItem item) { _locker.WaitOne(); lock (_locker) { DictionaryItem realItem = item.GetRealItem(); return(Items.Contains(realItem)); } }
public void RemoveItem(DictionaryItem item) { _locker.WaitOne(); lock (_locker) { try { DictionaryItem realItem = item.GetRealItem(); if (realItem == null || !Items.Contains(realItem)) { return; } Items.Remove(realItem); WriteData(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } }