PowerThreadPool 1.3.1
.NET 5.0
This package targets .NET 5.0. The package is compatible with this framework or higher.
.NET Framework 4.6
This package targets .NET Framework 4.6. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package PowerThreadPool --version 1.3.1
NuGet\Install-Package PowerThreadPool -Version 1.3.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="PowerThreadPool" Version="1.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PowerThreadPool --version 1.3.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PowerThreadPool, 1.3.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.
// Install PowerThreadPool as a Cake Addin #addin nuget:?package=PowerThreadPool&version=1.3.1 // Install PowerThreadPool as a Cake Tool #tool nuget:?package=PowerThreadPool&version=1.3.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PowerThreadPool
<img src="https://www.nuget.org/Content/gallery/img/logo-header.svg?sanitize=true" height="30px">
Enables efficient ThreadPool management with callback implementation, granular control, customizable concurrency, and support for diverse task submissions.
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
}
});
// DO SOMETHING
powerPool.Pause(id); // Pause by ID
powerPool.Pause(); // Pause all running thread
powerPool.Resume(true); // Resume all thread
API Summary
PowerPool
name | summary | result |
---|---|---|
QueueWorkItem<...>(...) | Queues a method for execution. The method executes when a thread pool thread becomes available. | thread id |
Wait() | Blocks the calling thread until all of the threads terminates. | - |
WaitAsync() | Blocks the calling thread until all of the threads terminates. | Task |
Stop(bool forceStop = false) | Stop all threads. If forceStop is true, Thread.Interrupt() and Thread.Join() will be called. | - |
StopAsync(bool forceStop = false) | Stop all threads. If forceStop is true, Thread.Interrupt() and Thread.Join() will be called. | Task |
Stop(string id, bool forceStop = false) | Stop thread by id. If forceStop is true, Thread.Interrupt() and Thread.Join() will be called. | If thread is in progress during the invocation |
StopAsync(string id, bool forceStop = false) | Stop thread by id. If forceStop is true, Thread.Interrupt() and Thread.Join() will be called. | (Task) If thread is in progress during the invocation |
PauseIfRequested() | Call this function inside the thread logic where you want to pause when user call Pause(...) | - |
StopIfRequested() | Call this function inside the thread logic where you want to stop when user call Stop(...) | - |
CheckIfRequestedStop() | Call this function inside the thread logic where you want to check if requested stop (if user call Stop(...)) | - |
Pause() | Pause all threads | - |
Resume(bool resumeThreadPausedById = false) | Resume all threads | - |
Pause(string id) | Pause thread by id | - |
Resume(string id) | Resume thread by id | - |
Cancel() | Cancel all tasks that have not started running | - |
Cancel(string id) | Cancel the task by id if the task has not started running | is succeed |
API List
PowerPool
Properties
ThreadPoolOption ThreadPoolOption; // Get, Set
int WaitingThreadCount; // Get
IEnumerable<string> WaitingThreadList; // Get
int RunningThreadCount; // Get
IEnumerable<string> RunningThreadList; // Get
Events
event ThreadPoolStartEventHandler ThreadPoolStart;
event IdleEventHandler Idle;
event ThreadStartEventHandler ThreadStart;
event ThreadEndEventHandler ThreadEnd;
event ThreadPoolTimeoutEventHandler ThreadPoolTimeout;
event ThreadTimeoutEventHandler ThreadTimeout;
Methods
string QueueWorkItem(Action action, Action<ExcuteResult<object>> callBack = null);
string QueueWorkItem(Action action, ThreadOption option);
string QueueWorkItem(Action<object[]> action, object[] param, Action<ExcuteResult<object>> callBack = null);
string QueueWorkItem(Action<object[]> action, object[] param, ThreadOption option);
string QueueWorkItem<T1>(Action<T1> action, T1 param1, Action<ExcuteResult<object>> callBack = null);
string QueueWorkItem<T1>(Action<T1> action, T1 param1, ThreadOption option);
string QueueWorkItem<T1, T2>(Action<T1, T2> action, T1 param1, T2 param2, Action<ExcuteResult<object>> callBack = null);
string QueueWorkItem<T1, T2>(Action<T1, T2> action, T1 param1, T2 param2, ThreadOption option);
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>(Action<T1, T2, T3> action, T1 param1, T2 param2, T3 param3, ThreadOption option);
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>(Action<T1, T2, T3, T4> action, T1 param1, T2 param2, T3 param3, T4 param4, ThreadOption option);
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, T2, T3, T4, T5>(Action<T1, T2, T3, T4, T5> action, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, ThreadOption option);
string QueueWorkItem<T1, TResult>(Func<T1, TResult> function, T1 param1, Action<ExcuteResult<TResult>> callBack = null);
string QueueWorkItem<T1, TResult>(Func<T1, TResult> function, T1 param1, ThreadOption option);
string QueueWorkItem<T1, T2, TResult>(Func<T1, T2, TResult> function, T1 param1, T2 param2, Action<ExcuteResult<TResult>> callBack = null);
string QueueWorkItem<T1, T2, TResult>(Func<T1, T2, TResult> function, T1 param1, T2 param2, ThreadOption option);
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, TResult>(Func<T1, T2, T3, TResult> function, T1 param1, T2 param2, T3 param3, ThreadOption option);
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, TResult>(Func<T1, T2, T3, T4, TResult> function, T1 param1, T2 param2, T3 param3, T4 param4, ThreadOption option);
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<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult> function, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, ThreadOption option);
string QueueWorkItem<TResult>(Func<TResult> function, Action<ExcuteResult<TResult>> callBack = null);
string QueueWorkItem<TResult>(Func<TResult> function, ThreadOption option);
string QueueWorkItem<TResult>(Func<object[], TResult> function, object[] param, Action<ExcuteResult<TResult>> callBack = null);
string QueueWorkItem<TResult>(Func<object[], TResult> function, object[] param, ThreadOption option);
void Wait();
async Task WaitAsync();
void Stop(bool forceStop = false);
async Task StopAsync(bool forceStop = false);
bool Stop(string id, bool forceStop = false);
async Task<bool> StopAsync(string id, bool forceStop = false);
void PauseIfRequested();
void StopIfRequested();
bool CheckIfRequestedStop();
void Pause();
void Resume(bool resumeThreadPausedById = false);
void Pause(string id);
void Resume(string id);
void Cancel();
bool Cancel(string id);
ExcuteResult<TResult>
Properties
string ID // Get
TResult Result; // Get
Status Status; // Get
Exception Exception; // Get
Status
enum Status { Succeed, Failed }
ThreadPoolOption
Properties
int MaxThreads; // Get, Set
TimeoutOption Timeout; // Get, Set
TimeoutOption DefaultThreadTimeout; // Get, Set
Action<ExecuteResult<object>> DefaultCallback; // Get, Set
ThreadOption
Properties
TimeoutOption Timeout; // Get, Set
Action<ExecuteResult<TResult>> Callback; // Get, Set
int Priority; // Get, Set
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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 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. |
.NET Framework | net46 is compatible. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETFramework 4.7.2
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.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.12.0 | 85 | 10/16/2024 | |
4.11.1 | 103 | 9/29/2024 | |
4.11.0 | 92 | 9/24/2024 | |
4.10.0 | 110 | 9/18/2024 | |
4.9.1 | 133 | 9/1/2024 | |
4.9.0 | 127 | 8/24/2024 | |
4.8.2 | 110 | 8/18/2024 | |
4.8.1 | 89 | 7/27/2024 | |
4.8.0 | 132 | 7/21/2024 | |
4.7.0 | 114 | 7/18/2024 | |
4.6.0 | 100 | 6/30/2024 | |
4.5.1 | 128 | 5/29/2024 | |
4.5.0 | 117 | 5/24/2024 | |
4.4.0 | 86 | 5/20/2024 | |
4.3.0 | 100 | 5/16/2024 | |
4.2.0 | 100 | 5/13/2024 | |
4.1.0 | 104 | 5/11/2024 | |
4.0.4 | 115 | 5/9/2024 | |
4.0.3 | 134 | 5/5/2024 | |
4.0.2 | 118 | 5/4/2024 | |
4.0.1 | 95 | 4/27/2024 | |
4.0.0 | 110 | 4/24/2024 | |
3.2.0 | 113 | 4/22/2024 | |
3.1.0 | 114 | 4/20/2024 | |
3.0.0 | 94 | 4/18/2024 | |
2.5.11 | 114 | 4/15/2024 | |
2.5.10 | 105 | 4/12/2024 | |
2.5.9 | 107 | 4/8/2024 | |
2.5.8 | 137 | 3/26/2024 | |
2.5.7 | 126 | 3/22/2024 | |
2.5.6 | 124 | 3/12/2024 | |
2.5.5 | 154 | 3/2/2024 | |
2.5.4 | 106 | 2/29/2024 | |
2.5.3 | 122 | 2/29/2024 | |
2.5.2 | 133 | 2/26/2024 | |
2.5.1 | 116 | 2/25/2024 | |
2.5.0 | 146 | 2/8/2024 | |
2.4.0 | 213 | 12/5/2023 | |
2.3.0 | 109 | 12/5/2023 | |
2.2.3 | 125 | 12/4/2023 | |
2.2.2 | 114 | 12/3/2023 | |
2.2.1 | 150 | 11/21/2023 | |
2.2.0 | 117 | 11/12/2023 | |
2.1.4 | 96 | 11/11/2023 | |
2.1.3 | 100 | 11/11/2023 | |
2.1.2 | 107 | 11/11/2023 | |
2.1.1 | 108 | 11/6/2023 | |
2.1.0 | 103 | 11/5/2023 | |
2.0.1 | 137 | 10/23/2023 | |
2.0.0 | 130 | 10/22/2023 | |
1.5.10 | 138 | 9/24/2023 | |
1.5.9 | 131 | 9/24/2023 | |
1.5.8 | 116 | 9/18/2023 | |
1.5.7 | 105 | 9/17/2023 | |
1.5.6 | 130 | 9/8/2023 | |
1.5.5 | 125 | 9/7/2023 | |
1.5.4 | 137 | 9/6/2023 | |
1.5.3 | 141 | 9/5/2023 | |
1.5.2 | 120 | 9/4/2023 | |
1.5.1 | 140 | 9/3/2023 | |
1.5.0 | 140 | 9/2/2023 | |
1.4.5 | 144 | 9/1/2023 | |
1.4.4 | 127 | 9/1/2023 | |
1.4.3 | 124 | 8/31/2023 | |
1.4.2 | 129 | 8/30/2023 | |
1.4.1 | 207 | 8/30/2023 | |
1.4.0 | 162 | 8/30/2023 | |
1.3.2 | 155 | 8/29/2023 | |
1.3.1 | 144 | 8/28/2023 | |
1.3.0 | 153 | 8/28/2023 | |
1.2.1 | 149 | 8/28/2023 | |
1.2.0 | 145 | 8/27/2023 | |
1.1.0 | 156 | 8/27/2023 | |
1.0.2 | 143 | 8/26/2023 | |
1.0.1 | 144 | 8/26/2023 | |
1.0.0 | 142 | 8/26/2023 |