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 as a Cake Addin
#tool nuget:?package=PowerThreadPool&version=1.0.0
                    
Install 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.  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.
  • 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.20.0 136 6/18/2025
4.19.0 126 6/17/2025
4.18.3 297 6/10/2025
4.18.2 156 5/29/2025
4.18.1 221 5/16/2025
4.18.0 158 5/8/2025
4.17.0 151 4/27/2025
4.16.4 195 3/20/2025
4.16.3 178 3/3/2025
4.16.2 142 2/21/2025
4.16.1 156 2/4/2025
4.16.0 136 1/19/2025
4.15.0 141 1/3/2025
4.14.2 150 12/18/2024
4.14.1.1 141 12/13/2024
4.14.1 131 12/13/2024 4.14.1 is deprecated because it has critical bugs.
4.14.0 138 12/4/2024
4.13.0 151 11/14/2024
4.12.1 144 11/9/2024
4.12.0 170 10/16/2024
4.11.1 149 9/29/2024
4.11.0 131 9/24/2024
4.10.0 203 9/18/2024
4.9.1 183 9/1/2024
4.9.0 165 8/24/2024
4.8.2 158 8/18/2024
4.8.1 125 7/27/2024
4.8.0 175 7/21/2024
4.7.0 163 7/18/2024
4.6.0 142 6/30/2024
4.5.1 172 5/29/2024
4.5.0 150 5/24/2024
4.4.0 122 5/20/2024
4.3.0 139 5/16/2024
4.2.0 141 5/13/2024
4.1.0 145 5/11/2024
4.0.4 156 5/9/2024
4.0.3 212 5/5/2024
4.0.2 166 5/4/2024
4.0.1 137 4/27/2024
4.0.0 149 4/24/2024
3.2.0 144 4/22/2024
3.1.0 149 4/20/2024
3.0.0 134 4/18/2024
2.5.11 155 4/15/2024
2.5.10 139 4/12/2024
2.5.9 143 4/8/2024
2.5.8 173 3/26/2024
2.5.7 159 3/22/2024
2.5.6 157 3/12/2024
2.5.5 189 3/2/2024
2.5.4 139 2/29/2024
2.5.3 155 2/29/2024
2.5.2 170 2/26/2024
2.5.1 154 2/25/2024
2.5.0 189 2/8/2024
2.4.0 234 12/5/2023
2.3.0 135 12/5/2023
2.2.3 144 12/4/2023
2.2.2 132 12/3/2023
2.2.1 172 11/21/2023
2.2.0 138 11/12/2023
2.1.4 126 11/11/2023
2.1.3 125 11/11/2023
2.1.2 127 11/11/2023
2.1.1 134 11/6/2023
2.1.0 125 11/5/2023
2.0.1 162 10/23/2023
2.0.0 155 10/22/2023
1.5.10 159 9/24/2023
1.5.9 154 9/24/2023
1.5.8 140 9/18/2023
1.5.7 130 9/17/2023
1.5.6 154 9/8/2023
1.5.5 155 9/7/2023
1.5.4 173 9/6/2023
1.5.3 175 9/5/2023
1.5.2 144 9/4/2023
1.5.1 169 9/3/2023
1.5.0 163 9/2/2023
1.4.5 167 9/1/2023
1.4.4 155 9/1/2023
1.4.3 149 8/31/2023
1.4.2 155 8/30/2023
1.4.1 239 8/30/2023 1.4.1 is deprecated because it has critical bugs.
1.4.0 193 8/30/2023 1.4.0 is deprecated because it has critical bugs.
1.3.2 180 8/29/2023
1.3.1 169 8/28/2023
1.3.0 175 8/28/2023
1.2.1 174 8/28/2023
1.2.0 170 8/27/2023
1.1.0 186 8/27/2023
1.0.2 169 8/26/2023
1.0.1 168 8/26/2023
1.0.0 170 8/26/2023