protected void Debounce(object obj, int interval, Action <object> debounceAction) { LastObjectDebounced = obj; DebounceAction = debounceAction; DebounceTimerInterval?.Dispose(); DebounceTimerInterval = new Timer(DebounceTimerIntervalOnTick, obj, interval, interval); }
protected void DebounceTimerIntervalOnTick(object state) { DebounceTimerInterval?.Dispose(); if (DebounceTimerInterval != null) { DebounceAction?.Invoke(LastObjectDebounced); } DebounceTimerInterval = null; }