GPS.SimpleThreading 3.0.0

SimpleThreading is a small library of collections and blocks aimed to simplify parallel coding.

There is a newer version of this package available.
See the version list below for details.
Install-Package GPS.SimpleThreading -Version 3.0.0
dotnet add package GPS.SimpleThreading --version 3.0.0
<PackageReference Include="GPS.SimpleThreading" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GPS.SimpleThreading --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GPS.SimpleThreading, 3.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install GPS.SimpleThreading as a Cake Addin
#addin nuget:?package=GPS.SimpleThreading&version=3.0.0

// Install GPS.SimpleThreading as a Cake Tool
#tool nuget:?package=GPS.SimpleThreading&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SimpleMVC

What is it?

SimpleThreading is a set of classes to ease your multithreading.
There is a very simple ThreadBlock class to work with that allows you to get a result from each delegate call, unlike the ActionBlock Microsoft provides.

How do you use it?

SimpleThreading is a stand-alone library that you can use very easily. Simply import the NuGet package __GPS.SimpleThreading__ into your project.

ThreadBlock

Example:

    // Structure to write to on-the-fly.
    var results = new ConcurrentDictionary<string, int>();

    var block = new ThreadBlock<string, int>(
        // Lambda defining processing action per item
        item =>
        {
            var result = 0;
            return int.TryParse(item, out result) ? result : 0;
        },
        // Lambda defining processing action for end of batch
        results => 
        {
            Debug.WriteLine($"Sum: {results.Where(r => r != null).Sum(r => r.result)}");
        });
        
    // Add data to be processed.
    block.AddRange(new List<string>{ "1", "2", "3", "four", "5", "six", "7", "8", "nine", "10"});

    // Lock the list, preventing data from being added during processing.
    block.LockList();

    // Execute the batch
    block.Execute(
        // Max Degree of Parallelism
        5,  
        // Warmup code for the item.  Executed before the 
        // main lambda.
        (item) => Debug.WriteLine($"Processing {item}.")
        // Continuation code per item.
        (item, result) =>
        {
            results.Add(item, result);
        });

    // Display completed results
    results.ToList().ForEach(
        r => Console.Debug($"{r.Key} - {r.Value}"));

Where can I get it?

SimpleThreading is available on Nuget.org for easy inclusion in your .Net application from within Visual Studio. Simply open the Package Manager Console and type:

install-package GPS.SimpleThreading

Alternatively, you may download the package from GitHub.

Where can I get help?

You can log and track issues on GitHub or you can send an email to The Sharp Ninja.

What's this Gateway Programming School?

Gateway Programming School (or GPS for short) is a programming school in Clarksville, TN that is funding its startup costs through the creation of useful applications, frameworks and text books. GPS is a for profit school with the express goal of providing a first-class education in business-oriented computer programming in DotNet Core and related technologies.

SimpleMVC

What is it?

SimpleThreading is a set of classes to ease your multithreading.
There is a very simple ThreadBlock class to work with that allows you to get a result from each delegate call, unlike the ActionBlock Microsoft provides.

How do you use it?

SimpleThreading is a stand-alone library that you can use very easily. Simply import the NuGet package __GPS.SimpleThreading__ into your project.

ThreadBlock

Example:

    // Structure to write to on-the-fly.
    var results = new ConcurrentDictionary<string, int>();

    var block = new ThreadBlock<string, int>(
        // Lambda defining processing action per item
        item =>
        {
            var result = 0;
            return int.TryParse(item, out result) ? result : 0;
        },
        // Lambda defining processing action for end of batch
        results => 
        {
            Debug.WriteLine($"Sum: {results.Where(r => r != null).Sum(r => r.result)}");
        });
        
    // Add data to be processed.
    block.AddRange(new List<string>{ "1", "2", "3", "four", "5", "six", "7", "8", "nine", "10"});

    // Lock the list, preventing data from being added during processing.
    block.LockList();

    // Execute the batch
    block.Execute(
        // Max Degree of Parallelism
        5,  
        // Warmup code for the item.  Executed before the 
        // main lambda.
        (item) => Debug.WriteLine($"Processing {item}.")
        // Continuation code per item.
        (item, result) =>
        {
            results.Add(item, result);
        });

    // Display completed results
    results.ToList().ForEach(
        r => Console.Debug($"{r.Key} - {r.Value}"));

Where can I get it?

SimpleThreading is available on Nuget.org for easy inclusion in your .Net application from within Visual Studio. Simply open the Package Manager Console and type:

install-package GPS.SimpleThreading

Alternatively, you may download the package from GitHub.

Where can I get help?

You can log and track issues on GitHub or you can send an email to The Sharp Ninja.

What's this Gateway Programming School?

Gateway Programming School (or GPS for short) is a programming school in Clarksville, TN that is funding its startup costs through the creation of useful applications, frameworks and text books. GPS is a for profit school with the express goal of providing a first-class education in business-oriented computer programming in DotNet Core and related technologies.

Release Notes

Version 3.0.0
Payton Byrd (The Sharp Ninja)

* Removed Paket
* Refactored projects for Netstandard 2.0
* Added per-item continuation
* Changed return types to inferred tuples containing the source data and result.

Dependencies

This package has no dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on GPS.SimpleThreading:

Package Downloads
GPS.SimpleCache
Simple Caching
ArchMastery.Reflector.Core
Core library for ArchMastery.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
4.0.0 42 7/15/2021
3.0.1 474 2/7/2019
3.0.0 332 2/5/2019
2.0.0.1 569 8/7/2017
2.0.0 507 8/4/2017
1.0.1 535 7/31/2017
1.0.0 762 7/27/2017