AsyncPlinq 1.0.0

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

AsyncPlinq: Async Parallel Linq

#

Small library to set up TPL based parallel pipelines using simple LINQ style queries.

Convert a LINQ query like this:

var output = input.Select(i => Something(i)).Where(i => SomethingElse(i)).ToList();

into an async LINQ query that runs each stage with a certain degree of parallelism.

var output = await input.SelectAsync(i => SomethingAsync(i)).WhereAsync(i => SomethingElseAsync(i)).ToListAsync();

The first query has the following run characteristics:

One at the time processing of a linq query

while the variant with SelectAsync and WhereAsync looks more like:

One at the time processing of a linq query

Why this package?

Using async predicates or selectors in LINQ queries is always a bit difficult. Before .NET 10 there was no way of running async predicates or selectors easily.

One would be tempted to convert the first query into something like this, but that will result in excessive parallelism.

var intermediate = await Task.WhenAll(input.Select(async i => SomethingAsync(i)));
// [..]

Excessive parallelism

Using LINQ for IAsyncEnumerable makes it more easy, but does not run the selector and predicate in parallel:

var output = await input.Select((i, index, ct) => SomethingAsync(i)).Where((i, index, ct) => SomethingElseAsync(i)).ToListAsync();

IAsyncEnumerable LINQ

Converting it to a TPL Pipeline to get to the same characteristics introduces a lot of extra stuff:

var selectBlock = new TransformBlock<int, int>(
    async x => SomethingAsync(x), 
    new() { MaxDegreeOfParallelism = 5 });
var whereBlock = new TransformManyBlock<int, int>(
    async x => SomethingElseAsync(x), 
    new() { MaxDegreeOfParallelism = 5 });

whereBlock.LinkTo(selectBlock, new() { PropagateCompletion = true });

foreach (var item in _data)
{
    await whereBlock.SendAsync(item);
}

whereBlock.Complete();

var data = await selectBlock.ReceiveAllAsync().ToArrayAsync();

return data;

Per stage parallelism

With this library its possible to configure the following LINQ query, allowing you to configure the degree of parallelism per step in the query:

var output = await input
    .SelectAsync(async i => SomethingAsync(i), 2)
    .WhereAsync(async i => SomethingReallySlowAsync(i), 5)
    .SelectAsync(async i => SomethingFastAsync(i), 1)
    .WhereAsync(async i => SomethingSlowAsync(i), 10)
    .ToArrayAsync();

Multi-stage parallel query

Since this library processes all items eagerly, running an async parallel LINQ query with FirstOrDefaultAsync() will result in some wasted work:

var output = await input
    .SelectAsync(async i => SomethingAsync(i), 2)
    .WhereAsync(async i => SomethingReallySlowAsync(i), 5)
    .SelectAsync(async i => SomethingFastAsync(i), 1)
    .WhereAsync(async i => SomethingSlowAsync(i), 10)
    .FirstOrDefaultAsync();

Multi-stage parallel query that gets cancelled after the first result

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 696 9/23/2025
1.0.0-preview-3 347 9/16/2025