budul.ProgressWatcher 3.1.0

dotnet add package budul.ProgressWatcher --version 3.1.0
                    
NuGet\Install-Package budul.ProgressWatcher -Version 3.1.0
                    
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="budul.ProgressWatcher" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="budul.ProgressWatcher" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="budul.ProgressWatcher" />
                    
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 budul.ProgressWatcher --version 3.1.0
                    
#r "nuget: budul.ProgressWatcher, 3.1.0"
                    
#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 budul.ProgressWatcher@3.1.0
                    
#: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=budul.ProgressWatcher&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=budul.ProgressWatcher&version=3.1.0
                    
Install as a Cake Tool

ProgressWatcher

Lightweight, thread-safe progress coordination library for nested and parallel operations.

Overview

ProgressWatcher provides a small API to create progress packages (IPackage) and a top-level Watcher that aggregates progress and status information for UI or logging consumers. Packages support nested child packages, fractional progress reporters (IProgress<double>), and efficient thread-local batching for high-concurrency scenarios.

Installation

Install from NuGet:

dotnet add package budul.ProgressWatcher

Quick start (synchronous)

using ProgressWatcher;

var watcher = new Watcher(); 
var package = watcher.GetPackage(allSteps: 3, status: "Starting work...");

package.NextStep("Step 1 done"); 
package.NextStep("Step 2 done"); 
package.NextStep("Step 3 done");
package.Dispose(); // or package.Complete() 

// watcher.ProgressAll, watcher.ProgressTip and watcher.Status update via PropertyChanged

Parallel usage (hot loops)

For high-concurrency loops (e.g. Parallel.ForEach or many threads) use NextStepLocal() to avoid contention. After the loop finishes, call FlushCounterLocal() to ensure any thread-local counts are aggregated and reported.

using ProgressWatcher; 
using System.Threading.Tasks;

var items = Enumerable.Range(0, 1_000_000); 

var watcher = new Watcher(); 
var package = watcher.GetPackage(items, "Processing items");

Parallel.ForEach(items, item => { // work on item...
	// report work from current thread using thread-local batching
	package.NextStepLocal();
});

// ensure remaining local counts are flushed 
package.FlushCounterLocal(); 
package.Dispose();

Important notes:

  • Always call FlushCounterLocal() after a parallel loop; otherwise some thread-local counts may remain unreported.
  • NextStepLocal() is intended for hot/tight loops and batches updates on a per-thread basis to reduce synchronization costs.

Using progress reporters and weights

Get a fractional progress reporter when you need to report continuous progress from a subtask:

var parent = watcher.GetPackage(status: "Parent", steps: 1); 

using var reporter = parent.GetProgress(status: "Loading", steps: 10, weight: 0.5)
{
	reporter.NextStep(4);
}

parent.Dispose();

Weights:

  • weight is a value in [0.0, 1.0] that assigns how much of the parent's remaining progress the child consumes.
  • Passing 0 uses automatic weight calculation based on remaining steps.

Nesting and lifecycle

  • Create nested work with GetPackage(...) or fractional reporters with GetProgress(...).
  • Call Dispose() on a package to complete it and notify the parent. Complete() sets progress to 100% immediately.
  • Top-level Watcher exposes events: ProgressStarted, ProgressCompleted, ChildStarted, ChildDisposed and properties ProgressAll, ProgressTip, Status, IsRunning (useful for UI binding).

Thread-safety and throttling

  • Package is designed for concurrent reporting. Use NextStepLocal() in parallel scenarios and FlushCounterLocal() afterwards.
  • Progress updates are internally throttled using a minimum delta and minimum interval before forwarding to the parent. This avoids flooding UI updates while remaining responsive.

Best practices

  • Prefer NextStepLocal() inside parallel loops; call FlushCounterLocal() after the loop.
  • Dispose or Complete() packages to ensure parents advance to completion.
  • Use GetProgress(...) for long-running subtasks that report fractional progress.

API summary

  • Watcher � top-level aggregator; use GetPackage(...) to start work and bind to ProgressAll, ProgressTip, Status.
  • IPackage � use NextStep(), NextStepLocal(), GetPackage(...), GetProgress(...), FlushCounterLocal(), Complete(), Dispose().
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on budul.ProgressWatcher:

Package Downloads
budul.ChainFinder

Generic helper library to build chains (connected paths) from directed elements such as track segments or graph edges.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 32 10/14/2026
3.0.0 35 10/14/2026
2.1.0 623 12/10/2025
2.0.0 513 12/9/2025
1.3.0 355 8/6/2025
1.2.0 333 3/6/2025
1.1.3 245 12/20/2024
1.1.2 234 11/10/2024
1.1.1 237 11/10/2024
1.1.0 223 11/10/2024
1.0.1 328 6/18/2023
1.0.0 279 6/18/2023