I'm registering to an event of a UserControl, this event is thrown every time I move a scrollbar(meaning that we will receive a lot of events). Unfortunately, we have no events to be informed when the user finished to use the scrollbar(== MouseUp).
We decided to implement a mechanism to update our models only once we didn't receive any new notifications from the scrollbar since 300ms.
I can see how to do this with a Timer and reseting the timer everytime the ScrollBar event is comming.
I was wondering if there was a way to do it with Linq and Delay?
private Action _actionOnMoved;
private void OnScrollBarMoved(object sender, EventArgs args){
}
EDIT
I've read the potentially duplicated answer, but Throttling is not the same thing that what I'm asking. In my case, as far I've event coming in less than the specified time, I don't want to do anything(not even the first one), since applying this change will take 3-5 seconds to be retrieved.
So what differs:
- In the given link, the first call is executed no matter what
- In my case, if a call is made within the delay, the call should still be executed AFTER the delay
By example, if this event is triggered every 100ms, and that the delay is 300ms, I expect to never have my method called.