void QueueAction(MyAction action, bool unique) { bool start; lock (lockObj) { if (unique) { for (int i = 0; i < actions.Count; i++) { if (actions[i].GetType() == action.GetType()) { actions.RemoveAt(i); break; } } } actions.Add(action); start = actions.Count == 1; } if (start) { dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(EmptyQueue)); } }
void QueueAction(MyAction action, bool unique) { bool start; lock (lockObj) { if (unique) { for (int i = 0; i < actions.Count; i++) { if (actions[i].GetType() == action.GetType()) { actions.RemoveAt(i); break; } } } actions.Add(action); start = actions.Count == 1; } if (start) dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(EmptyQueue)); }