Skip to main content
net8.0

Async utility methods for Linq and PLinq queries.

Published
Sep 9, 2024
2y ago
Total Downloads
2.2K
2,155

Install

dotnet add package Iciclecreek.Async --version 1.0.0
ProductVersions
.NET
net8.0

README

Iciclecreek.Async

Async extensions for LINQ and PLINQ queries

SelectParallelAsync()

This allows you to run an async select task which runs each task in parallel, with max parallelism.

You can use it with a normal enumerable:

    // using an enumerable, will max 10 tasks at a time concurrently
    var results = enumerable
        .SelectParallelAsync(async (item, index) =>
        {
            await ...;
            return result;
        }, maxParallel: 10)
        .ToList();

You can use it with a ParallelQuery

    // using an enumerable, will max 10 tasks at a time concurrently
    var results = enumerable
        .AsParallel()
        .WithDegreeOfParallelism(10)
        .SelectParallelAsync(async (item, index) =>
        {
            await ...;
            return result;
        })
        .ToList();

WaitAll()

WaitAll() will await all items in an enumerable of Task<> and return the result of the tasks.

    var results = enumerable
        .Select(async (item) => 
        {
            await ...;
            return result;
        })
        .WaitAll() // turns IEnumerable<Task<X>> => IEnumerable<X>

NOTE: You don't need to use WaitAll() on result of SelectParallelAsync(). It does the equivelent of WaitAll() internally.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.