ParallelHelperEx 1.0.5

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

ParallelHelperEx

A modern C# library for efficient, parallel, and asynchronous processing of collections with real-time metrics reporting.

Features

  • Parallel processing with configurable degree of parallelism
  • Streaming/iterator-based input (no forced materialization)
  • Real-time metrics via IProgress<ParallelProcessingMetrics>
  • Graceful error handling (errors are logged, processing continues)
  • Proper resource cleanup with IAsyncDisposable

Installation

Add the ParallelHelperEx project to your solution and reference it from your project.

Usage Examples

Parallel ForEach (Action)

using ParallelHelperEx;

var items = Enumerable.Range(1, 1000);
await items.ParallelForEachAsync(async item =>
{
    // Your async work here
    await Task.Delay(10);
});

Parallel ForEach with Cancellation, Logging, and Metrics

var cts = new CancellationTokenSource();
var logger = /* your ILogger instance */;
var progress = new Progress<ParallelProcessingMetrics>(m =>
{
    Console.WriteLine($"Processed: {m.ProcessedCount}, Errors: {m.ErrorCount}, Elapsed: {m.Elapsed.TotalSeconds:F1}s, Throughput: {m.ItemsProcessedPerSecond:F2}/sec");
});

await items.ParallelForEachAsync(
    async (item, ct) => { /* ... */ },
    maxDegreeOfParallelism: 8,
    logger: logger,
    progress: progress,
    cancellationToken: cts.Token
);

Parallel Select (Transform)

var results = await items.ParallelSelectAsync(async item =>
{
    await Task.Delay(5);
    return item * 2;
}, maxDegreeOfParallelism: 4);

Metrics Reporting

The ParallelProcessingMetrics class provides:

  • ProcessedCount: Number of items processed
  • ErrorCount: Number of errors encountered
  • StartTime, EndTime, Elapsed: Timing info
  • ItemsProcessedPerSecond: Throughput

Metrics are reported every second and once at the end.

Proper Disposal

If you use ToParallelQueue, always dispose:

await using var queue = items.ToParallelQueue(async item => { /* ... */ }, 4);
// ...
await queue.CompleteAsync();
// or just let the using block end

Best Practices

  • Use IProgress<ParallelProcessingMetrics> for real-time UI or logging.
  • Always dispose of queues with await using or DisposeAsync().
  • Tune maxDegreeOfParallelism for your workload.
  • For large or memory-sensitive workloads, consider making channel capacity configurable.

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ParallelHelperEx:

Package Downloads
PrimeNgScraperBase.core

base scraper backend with user manegment

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 182 8/7/2025
1.0.4 180 8/7/2025
1.0.3 190 8/6/2025
1.0.2 190 8/6/2025
1.0.1 224 7/26/2025