PowerThreadPool 1.0.0

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

PowerThreadPool

<img src="https://www.nuget.org/Content/gallery/img/logo-header.svg?sanitize=true" height="30px">

Enables efficient ThreadPool management. Features task queuing, thread control, and customizable concurrent execution. Supports diverse task submissions for complex concurrency requirements.

Download

PowerThreadPool is available as Nuget Package now.

Getting started

Without callback
PowerPool powerPool = new PowerPool(new ThreadPoolOption() { MaxThreads = 3 });
powerPool.QueueWorkItem(() => 
{
    // DO SOMETHING
    return result;
});
With callback
PowerPool powerPool = new PowerPool(new ThreadPoolOption() { MaxThreads = 3 });
powerPool.QueueWorkItem(() => 
{
    // DO SOMETHING
    return result;
}, (res) => 
{
    // this callback of thread
    // running result: res.Result
});
Stop all threads
powerPool.Stop();
Blocks the calling thread until all of the threads terminates.
powerPool.Wait();
Pause threads
PowerPool powerPool = new PowerPool(new ThreadPoolOption());
string id = powerPool.QueueWorkItem(() => 
{
    while (true)
    {
        // Pause here when user call Pause()
        powerPool.PauseIfRequested();
        // DO SOMETHING
    }
    return result;
});
// DO SOMETHING
powerPool.Pause(id); // Pause by ID
powerPool.Pause(); // Pause all running thread
powerPool.Resume(true); // Resume all thread
API
string QueueWorkItem(Action action, Action<ExcuteResult<object>> callBack = null)
string QueueWorkItem(Action<object[]> action, object[] param, Action<ExcuteResult<object>> callBack = null)
string QueueWorkItem<T1>(Action<T1> action, T1 param1, Action<ExcuteResult<object>> callBack = null)
string QueueWorkItem<T1, T2>(Action<T1, T2> action, T1 param1, T2 param2, Action<ExcuteResult<object>> callBack = null)
string QueueWorkItem<T1, T2, T3>(Action<T1, T2, T3> action, T1 param1, T2 param2, T3 param3, Action<ExcuteResult<object>> callBack = null)
string QueueWorkItem<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action, T1 param1, T2 param2, T3 param3, T4 param4, Action<ExcuteResult<object>> callBack = null)
string QueueWorkItem<T1, T2, T3, T4, T5>(Action<T1, T2, T3, T4, T5> action, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, Action<ExcuteResult<object>> callBack = null)
string QueueWorkItem<T1, TResult>(Func<T1, TResult> function, T1 param1, Action<ExcuteResult<TResult>> callBack = null)
string QueueWorkItem<T1, T2, TResult>(Func<T1, T2, TResult> function, T1 param1, T2 param2, Action<ExcuteResult<TResult>> callBack = null)
string QueueWorkItem<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> function, T1 param1, T2 param2, T3 param3, Action<ExcuteResult<TResult>> callBack = null)
string QueueWorkItem<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> function, T1 param1, T2 param2, T3 param3, T4 param4, Action<ExcuteResult<TResult>> callBack = null)
string QueueWorkItem<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult> function, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, Action<ExcuteResult<TResult>> callBack = null)
string QueueWorkItem<TResult>(Func<TResult> function, Action<ExcuteResult<TResult>> callBack = null)
string QueueWorkItem<TResult>(Func<object[], TResult> function, object[] param, Action<ExcuteResult<TResult>> callBack = null)
void Wait()
async Task WaitAsync()
void Stop()
async Task StopAsync()
void PauseIfRequested()
public void Pause()
void Resume(bool resumeThreadPausedById = false)
void Pause(string id)
void Resume(string id)
void Cancel()
bool Cancel(string id)
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.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
4.17.0 39 2 days ago
4.16.4 178 a month ago
4.16.3 157 2 months ago
4.16.2 123 2 months ago
4.16.1 135 3 months ago
4.16.0 120 3 months ago
4.15.0 128 4 months ago
4.14.2 134 4 months ago
4.14.1.1 126 5 months ago
4.14.1 112 5 months ago 4.14.1 is deprecated because it has critical bugs.
4.14.0 122 5 months ago
4.13.0 133 6 months ago
4.12.1 125 6 months ago
4.12.0 154 6 months ago
4.11.1 125 7 months ago
4.11.0 114 7 months ago
4.10.0 169 7 months ago
4.9.1 163 8 months ago
4.9.0 148 8 months ago
4.8.2 140 8 months ago
4.8.1 111 9 months ago
4.8.0 154 9 months ago
4.7.0 139 9 months ago
4.6.0 124 10 months ago
4.5.1 152 5/29/2024
4.5.0 136 5/24/2024
4.4.0 107 5/20/2024
4.3.0 122 5/16/2024
4.2.0 122 5/13/2024
4.1.0 126 5/11/2024
4.0.4 137 5/9/2024
4.0.3 166 5/5/2024
4.0.2 146 5/4/2024
4.0.1 119 4/27/2024
4.0.0 130 4/24/2024
3.2.0 130 4/22/2024
3.1.0 132 4/20/2024
3.0.0 115 4/18/2024
2.5.11 142 4/15/2024
2.5.10 124 4/12/2024
2.5.9 125 4/8/2024
2.5.8 157 3/26/2024
2.5.7 142 3/22/2024
2.5.6 141 3/12/2024
2.5.5 172 3/2/2024
2.5.4 126 2/29/2024
2.5.3 140 2/29/2024
2.5.2 151 2/26/2024
2.5.1 136 2/25/2024
2.5.0 174 2/8/2024
2.4.0 226 12/5/2023
2.3.0 125 12/5/2023
2.2.3 137 12/4/2023
2.2.2 126 12/3/2023
2.2.1 162 11/21/2023
2.2.0 130 11/12/2023
2.1.4 110 11/11/2023
2.1.3 111 11/11/2023
2.1.2 120 11/11/2023
2.1.1 123 11/6/2023
2.1.0 117 11/5/2023
2.0.1 150 10/23/2023
2.0.0 144 10/22/2023
1.5.10 152 9/24/2023
1.5.9 145 9/24/2023
1.5.8 131 9/18/2023
1.5.7 119 9/17/2023
1.5.6 143 9/8/2023
1.5.5 140 9/7/2023
1.5.4 158 9/6/2023
1.5.3 159 9/5/2023
1.5.2 134 9/4/2023
1.5.1 154 9/3/2023
1.5.0 154 9/2/2023
1.4.5 158 9/1/2023
1.4.4 142 9/1/2023
1.4.3 138 8/31/2023
1.4.2 141 8/30/2023
1.4.1 223 8/30/2023 1.4.1 is deprecated because it has critical bugs.
1.4.0 177 8/30/2023 1.4.0 is deprecated because it has critical bugs.
1.3.2 168 8/29/2023
1.3.1 157 8/28/2023
1.3.0 166 8/28/2023
1.2.1 162 8/28/2023
1.2.0 158 8/27/2023
1.1.0 172 8/27/2023
1.0.2 157 8/26/2023
1.0.1 157 8/26/2023
1.0.0 154 8/26/2023