DebounceThrottle 2.0.0
See the version list below for details.
dotnet add package DebounceThrottle --version 2.0.0
NuGet\Install-Package DebounceThrottle -Version 2.0.0
<PackageReference Include="DebounceThrottle" Version="2.0.0" />
paket add DebounceThrottle --version 2.0.0
#r "nuget: DebounceThrottle, 2.0.0"
// Install DebounceThrottle as a Cake Addin #addin nuget:?package=DebounceThrottle&version=2.0.0 // Install DebounceThrottle as a Cake Tool #tool nuget:?package=DebounceThrottle&version=2.0.0
C# Debounce and Throttle dispatchers
Debounce and Throttle dispatchers support asynchronous actions, handle exceptions. All Task results from dispatcher calls will be equal to result of the a single invoking.
Debounce demo
Show entered text after stopping pressing keys for 500 milliseconds
class Program
{
static void Main(string[] args)
{
string str = "";
var debounceDispatcher = new DebounceDispatcher(500);
while(true)
{
var key = Console.ReadKey(true);
//trigger when to stop and exit
if (key.Key == ConsoleKey.Escape) break;
str += key.KeyChar;
//every keypress iteration call dispatcher but the Action will be invoked only after stopping pressing and waiting 1000 milliseconds
debounceDispatcher.Debounce(() =>
{
Console.WriteLine($"{str} - {DateTime.UtcNow.ToString("hh:mm:ss.fff")}");
str = "";
});
}
}
}
Throttle demo
Call action every 100 milliseconds but invoke only once in 1000 milliseconds (after last invoking completed)
class Program
{
static void Main(string[] args)
{
bool stop = false;
//trigger when to stop and exit
Task.Run(() => { Console.ReadKey(true); stop = true; });
var throttleDispatcher = new ThrottleDispatcher(500);
do
{
//every iteration call dispatcher but the Action will be invoked only once in 500 milliseconds
throttleDispatcher.Throttle(() =>
{
Console.WriteLine($"{ DateTime.UtcNow.ToString("hh:mm:ss.fff") }");
});
//iteration every 100 milliseconds
Thread.Sleep(100);
}
while (!stop); //wait trigger to stop and exit
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on DebounceThrottle:
Package | Downloads |
---|---|
FatCat.Toolkit
Package Description |
|
ChrisKaczor.Wpf.Validation
WPF validation rules and extension methods to help with validation. |
|
Adens.DevToys.Shared
Adens.DevToys.Shared |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on DebounceThrottle:
Repository | Stars |
---|---|
glsorre/amethystwindows
[ARCHIVED] Automatic tiling window manager for Windows 10/11
|