I have a situation where our application receives notifications when information is updated. When we receives a notification, we will fetch the latest change in async fashion in a WPF application. What I like to do is when a flood of notification comes, it will accumulate and be throttled.
So if there were 10 notifications send to the client, the system will wait 5 seconds and call an async method to refresh. Every 5 seconds, it will request for latest changes 1 instead of requesting 10 times for changes.
Can someone guide me with an example on the best way to handle it?
You could use a DispatcherTimer
with 5 seconds Interval
. Start the timer whenever you receive a notification, provided that it's not already started. In the Tick
event handler stop the timer and refresh the displayed data.