VOOZH about

URL: https://www.nuget.org/packages/Soenneker.Utils.Debounce/

⇱ NuGet Gallery | Soenneker.Utils.Debounce 4.0.55


ο»Ώ

πŸ‘ Image
Soenneker.Utils.Debounce 4.0.55

Prefix Reserved
dotnet add package Soenneker.Utils.Debounce --version 4.0.55
 
 
NuGet\Install-Package Soenneker.Utils.Debounce -Version 4.0.55
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.Debounce" Version="4.0.55" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Debounce" Version="4.0.55" />
 
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.Debounce" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Utils.Debounce --version 4.0.55
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.Utils.Debounce, 4.0.55"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Utils.Debounce@4.0.55
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Utils.Debounce&version=4.0.55
 
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Debounce&version=4.0.55
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

πŸ‘ alternate text is missing from this package README image
πŸ‘ alternate text is missing from this package README image
πŸ‘ alternate text is missing from this package README image
πŸ‘ alternate text is missing from this package README image

πŸ‘ alternate text is missing from this package README image
Soenneker.Utils.Debounce

A utility that lets you debounce work in .NET. Give it a delay, async/sync delegate, and the Debouncer guarantees that multiple rapid calls collapse into exactly one invocation.


Why would I need this?

  • API calls: Prevent hammering a server while the user types.
  • Disk I/O: Batch frequent save requests into a single write.
  • Telemetry: Send aggregated metrics after bursts of activity.
  • Search boxes / auto-complete: React only after the user pauses typing.

Quick start

dotnet add package Soenneker.Utils.Debounce
using Soenneker.Utils.Debounce;

var debouncer = new Debouncer();

// Fire only once, 300 ms after the *last* request:
void OnTextChanged(string text)
{
 debouncer.Debounce(
 delayMs: 300,
 action: async ct =>
 {
 var results = await SearchAsync(text, ct);
 UpdateUI(results);
 });
}

void OnResize()
{
 debouncer.Debounce(
 delayMs: 250,
 action: () =>
 {
 // Runs on the thread-pool after 250 ms of quiescence
 SaveWindowLayout();
 });
}
Leading-edge execution

Pass runLeading: true if you want the first call to run immediately and the trailing call to run after the quiet period:

debouncer.Debounce(
 delayMs: 500,
 runLeading: true,
 action: ct => Logger.LogAsync("Burst started", ct));

Either wrap it in a using statement or dispose the debouncer when youοΏ½re done:

await debouncer.DisposeAsync();

DisposeAsync() waits for any in-flight work to finish, ensuring graceful shutdown.


Design highlights

  • Pure TPL: Built on System.Threading.Timer
  • Thread-safe: Internal state is guarded with Interlocked swaps.
  • Cancellation-friendly: Each queued delegate receives its own CancellationToken.
  • Zero allocations on idle: Work objects are created only when you call Debounce.
  • Tested: xUnit suite covering timing, cancellation, and disposal semantics.
Product Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Utils.Debounce:

Package Downloads
Soenneker.Quark.Suite

Shadcn-powered Blazor UI, refined and modular.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.55 0 6/19/2026
4.0.54 0 6/19/2026
4.0.53 18 6/18/2026
4.0.52 4,342 6/6/2026
4.0.51 103 6/5/2026
4.0.49 1,782 6/5/2026
4.0.48 10,422 4/23/2026
4.0.47 110 4/22/2026
4.0.46 10,385 3/13/2026
4.0.45 147 3/13/2026
4.0.41 313 3/12/2026
4.0.40 147 3/12/2026
4.0.38 760 3/11/2026
4.0.37 151 3/11/2026
4.0.36 150 3/10/2026
4.0.35 135 3/10/2026
4.0.34 133 3/10/2026
4.0.33 113 3/9/2026
4.0.32 657 3/9/2026
4.0.31 1,056 3/4/2026
Loading failed

Update dependency Soenneker.Extensions.Task to 4.0.123 (#267)