This library help you use Throttle
and Debounce
in your .NET projects.
For see what is rate limiting you can run sample app or watch online sample.
This library is Extension on object
type which can use for any type.
Read the article about rate-limiting in medium.
This available on Nuget Packge Manager
PM> Install-Package RateLimiting
This method give last object when interval
argument was fire time tick. For example: You have 20 item received less than 200 milisecond so debounceAction
invoked after 20th item received and wait for another item for 200 milisecond.
private void OnPointerMoved(object sender, PointerRoutedEventArgs pointerRoutedEventArgs)
{
pointerRoutedEventArgs.Pointer.Debounce(interval: 200, debounceAction: delegate(object o)
{
//Do any thing here you want in background
//For use UI code use ---> await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { });
});
}
This method give last object when interval
argument was fire time tick. For example: You have 20 item received and 3 of them become after 200 milisecond, So throttleAction
invoked when timer fired tick after 200 miliescond and get 3 item and invoked throttleAction
callback.
private void OnPointerMoved(object sender, PointerRoutedEventArgs pointerRoutedEventArgs)
{
pointerRoutedEventArgs.Pointer.Throttle(interval: 200, throttleAction: delegate(object o)
{
//Do any thing here you want in background
//For use UI code use ---> await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { });
});
}