A comprehensive and efficient low-contention thread pool for easily managing both sync and async workloads. It provides granular work control, flexible concurrency, and robust error handling.
$ dotnet add package PowerThreadPool![]()
A comprehensive and efficient low-contention thread pool for easily managing both sync and async workloads. It provides granular work control, flexible concurrency, and robust error handling.
This project is currently a Seed Project within the .NET Foundation. This means it is an "up and coming" project within the foundation to grow its community and ecosystem.
Task.Run.Access the Wiki in English | 中文 | 日本語.
Visit the DeepWiki for more information.
If you want to include PowerThreadPool in your project, you can install it directly from NuGet.
Support: Net40+ | Net5.0+ | netstandard2.0+
PTP is designed to be out-of-the-box. For simple works, you can get started without any complex configuration.
PowerPool powerPool = new PowerPool();
// Sync
powerPool.QueueWorkItem(() =>
{
// Do something
});
// Async
powerPool.QueueWorkItem(async () =>
{
// Do something
// await ...;
});
PowerPool powerPool = new PowerPool(new PowerPoolOption() { /* Some options */ });
// Sync
powerPool.QueueWorkItem(() =>
{
// Do something
return result;
}, (res) =>
{
// Callback of the work
});
// Async
powerPool.QueueWorkItem(async () =>
{
// Do something
// await ...;
}, (res) =>
{
// Callback of the work
});
PowerPool powerPool = new PowerPool(new PowerPoolOption() { /* Some options */ });
// Sync
powerPool.QueueWorkItem(() =>
{
// Do something
return result;
}, new WorkOption()
{
// Some options
});
// Async
powerPool.QueueWorkItem(async () =>
{
// Do something
// await ...;
}, new WorkOption()
{
// Some options
});
// Sync
WorkID QueueWorkItem<T1, ...>(Action<T1, ...> action, T1 param1, ..., *);
WorkID QueueWorkItem(Action action, *);
WorkID QueueWorkItem(Action<object[]> action, object[] param, *);
WorkID QueueWorkItem<T1, ..., TResult>(Func<T1, ..., TResult> function, T1 param1, ..., *);
WorkID QueueWorkItem<TResult>(Func<TResult> function, *);
WorkID QueueWorkItem<TResult>(Func<object[], TResult> function, object[] param, *);
// Async
WorkID QueueWorkItem<T1, ...>(Func<T1, ..., Task> asyncFunc, T1 param1, ..., _, *);
WorkID QueueWorkItem(Func<Task> asyncFunc, _, *);
WorkID QueueWorkItem(Func<object[], Task> asyncFunc, object[] param, _, *);
WorkID QueueWorkItem<T1, ..., TResult>(Func<T1, ..., Task<TResult>> asyncFunc, T1 param1, ..., _, *);
WorkID QueueWorkItem<TResult>(Func<Task<TResult>> asyncFunc, _, *);
WorkID QueueWorkItem<TResult>(Func<object[], Task<TResult>> asyncFunc, object[] param, _, *);
| Wildcard | Explanation |
|---|---|
| * | WorkOption | WorkOption<T>: The work option to customize the behavior of the work.Action<ExecuteResult<T>>: The callback to be invoked when the work is completed. |
| ... | Up to 5 type parameters are supported. |
| _ | An out parameter (Task | Task<ExecuteResult<TResult>>) that returns a Task representing the asynchronous execution of asyncFunc. |
powershell -File build.ps1 -Version {Version}
Testing And Performance Analysis | Feature Comparison | Knowledge Base
Get involved: Join our growing community
Thanks goes to these wonderful people (emoji key):
一条咸鱼 💻 | ZjzMisaka 💻 🚧 📖 | r00tee 🤔 | aadog 🐛 | RookieZWH 💬 | hebinary 💬 | lindexi 🐛 |
This project follows the all-contributors specification. Contributions of any kind welcome!