ParallelHelperEx 1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ParallelHelperEx --version 1.0.1
NuGet\Install-Package ParallelHelperEx -Version 1.0.1
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.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ParallelHelperEx" Version="1.0.1" />
<PackageReference Include="ParallelHelperEx" />
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.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ParallelHelperEx, 1.0.1"
#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.1
#: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.1
#tool nuget:?package=ParallelHelperEx&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 processedErrorCount
: Number of errors encounteredStartTime
,EndTime
,Elapsed
: Timing infoItemsProcessedPerSecond
: 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
orDisposeAsync()
. - Tune
maxDegreeOfParallelism
for your workload. - For large or memory-sensitive workloads, consider making channel capacity configurable.
License
MIT
Product | Versions 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.
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
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.