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.
#:package PowerThreadPool@1.0.0
                    
#: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=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 (1)

Showing the top 1 NuGet packages that depend on PowerThreadPool:

Package Downloads
aadog.RedisTagLock

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on PowerThreadPool:

Repository Stars
lindexi/lindexi_gd
博客用到的代码
Version Downloads Last Updated
6.1.0 133 4/7/2026
6.0.2 119 3/23/2026
6.0.1 135 2/15/2026
6.0.0 144 1/30/2026
6.0.0-rc.1 83 1/24/2026
5.7.0 139 1/8/2026
5.6.0 333 12/18/2025
5.5.2 351 12/14/2025
5.5.1 314 11/30/2025
5.5.0 238 11/23/2025
5.4.0 452 11/18/2025
5.3.0 219 11/15/2025
5.2.0 327 11/1/2025
5.1.1 227 10/24/2025
5.1.0 215 10/17/2025
5.0.0 277 10/10/2025
5.0.0-rc.2 154 10/3/2025
5.0.0-rc.1 185 9/29/2025
4.22.7 255 9/20/2025
1.0.0 283 8/26/2023
Loading failed