TaskMuxer 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TaskMuxer --version 1.0.1
                    
NuGet\Install-Package TaskMuxer -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="TaskMuxer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TaskMuxer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="TaskMuxer" />
                    
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 TaskMuxer --version 1.0.1
                    
#r "nuget: TaskMuxer, 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 TaskMuxer@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=TaskMuxer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=TaskMuxer&version=1.0.1
                    
Install as a Cake Tool

TaskMuxer

NuGet Version NuGet Downloads License: MIT

Task Multiplexer.

The purpose of this package is to provide the ability to reduce the amount of parallel repetitive work.

In practical terms, imagine a service that requests data from a slow external API serving multiple requests in parallel.

By using this library, for any number of parallel requests only one will be executed.

Tasks are being identified / segmented by a key and their respective return type.

Nuget

Usage

Registration

Locate the services registration and append one of:

  • .AddInstanceTaskMultiplexerNoLogger - use when no logging is required
  • .AddInstanceTaskMultiplexerWithILogger - use when the ILogger provider is available
  • .AddInstanceTaskMultiplexerWithILoggerFactory - use when the ILoggerFactory provider is available

ex.

// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    // ...
    services
        .AddInstanceTaskMultiplexerWithILogger();
    // ...
}

📝 If further customization is required, consider wiring up any of the ITaskMultiplexer implementations as required.

Code

Please check the ITaskMultiplexer interface for the API surface provided.

ex.

public class ItemsCountService
{
    readonly ITaskMultiplexer _taskMultiplexer;

    public ItemsCountService(ITaskMultiplexer taskMultiplexer) => _taskMultiplexer = taskMultiplexer;

    public async Task<long> GetCountOfItems(CancellationToken cancellationToken = default) =>
        await _taskMultiplexer.AddTask(
            "items_count",
            async ct =>
            {
                await Task.Delay(250, ct);
                return Random.Shared.Next();
            },
            cancellationToken
        );
}

Similar Projects

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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

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
2.1.1 268 11/16/2024
2.1.0 125 11/16/2024
2.0.1 5,174 11/22/2023
2.0.0 133 11/21/2023
1.0.13 1,950 9/15/2023
1.0.12 187 9/14/2023
1.0.11 422 9/13/2023
1.0.10 247 9/11/2023
1.0.9 196 9/10/2023
1.0.8 158 9/4/2023
1.0.7 180 9/1/2023
1.0.6 182 9/1/2023
1.0.5 190 8/31/2023
1.0.4 185 8/30/2023
1.0.3 192 8/28/2023
1.0.2 193 8/28/2023
1.0.1 199 8/27/2023
1.0.0 182 8/26/2023