NTDLS.DelegateThreadPooling
1.4.4
See the version list below for details.
dotnet add package NTDLS.DelegateThreadPooling --version 1.4.4
NuGet\Install-Package NTDLS.DelegateThreadPooling -Version 1.4.4
<PackageReference Include="NTDLS.DelegateThreadPooling" Version="1.4.4" />
paket add NTDLS.DelegateThreadPooling --version 1.4.4
#r "nuget: NTDLS.DelegateThreadPooling, 1.4.4"
// Install NTDLS.DelegateThreadPooling as a Cake Addin #addin nuget:?package=NTDLS.DelegateThreadPooling&version=1.4.4 // Install NTDLS.DelegateThreadPooling as a Cake Tool #tool nuget:?package=NTDLS.DelegateThreadPooling&version=1.4.4
NTDLS.DelegateThreadPooling
📦 Be sure to check out the NuGet package: https://www.nuget.org/packages/NTDLS.DelegateThreadPooling
High performance active thread pool where work items can be queued as delegate functions. Allows you to easily enqueue infinite FIFO worker items or enforce queue size, wait on collections of those items to complete, and total control over the pool size. Also allows for multiple pools, so that different workloads do not interfere with one another.
If you have ever been frustrated with System.Threading.ThreadPool, then this is likely the solution you are looking for.
private static readonly DelegateThreadPool _delegateThreadPool = new(10);
static void Main()
{
CollectionExample();
NoCollectionExample();
Console.WriteLine("Press [enter] to exit.");
Console.ReadLine();
_delegateThreadPool.Dispose();
}
private static void CollectionExample()
{
Console.WriteLine("CollectionExample: Starting to enqueue items...");
var queuedStates = _delegateThreadPool.CreateQueueStateCollection();
//Enqueue work items as delegate functions.
for (int i = 0; i < 100; i++)
{
queuedStates.Enqueue(() =>
{
Thread.Sleep(1000); //Do some work...
});
}
Console.WriteLine("Enqueue complete, waiting on completion.");
//Wait on all of the workitems to complete.
queuedStates.WaitForCompletion();
Console.WriteLine("All workers are complete.");
}
private static void NoCollectionExample()
{
Console.WriteLine("NoCollectionExample: Starting to enqueue items...");
var queueTokens = new List<QueueItemState<object>>();
//Enqueue work items as delegate functions.
for (int i = 0; i < 100; i++)
{
var queueItemState = _delegateThreadPool.Enqueue(() =>
{
Thread.Sleep(1000); //Do some work...
});
queueTokens.Add(queueItemState);
}
Console.WriteLine("Enqueue complete, waiting on completion.");
//Wait on all of the workitems to complete.
queueTokens.ForEach(t => t.WaitForCompletion());
Console.WriteLine("All workers are complete.");
}
Product | Versions 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 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 is compatible. 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. |
-
net6.0
- NTDLS.Semaphore (>= 3.3.3)
-
net7.0
- NTDLS.Semaphore (>= 3.3.3)
-
net8.0
- NTDLS.Semaphore (>= 3.3.3)
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 |
---|---|---|
1.5.8 | 94 | 10/22/2024 |
1.5.7 | 82 | 10/20/2024 |
1.5.6 | 96 | 10/20/2024 |
1.5.5 | 92 | 10/13/2024 |
1.5.4 | 89 | 10/13/2024 |
1.5.3 | 85 | 10/13/2024 |
1.5.1 | 95 | 10/8/2024 |
1.5.0 | 91 | 10/3/2024 |
1.4.9 | 88 | 10/3/2024 |
1.4.8 | 165 | 8/25/2024 |
1.4.7 | 139 | 8/24/2024 |
1.4.6 | 114 | 8/23/2024 |
1.4.5 | 113 | 8/23/2024 |
1.4.4 | 126 | 8/13/2024 |
1.4.3 | 122 | 8/13/2024 |
1.4.2 | 122 | 8/13/2024 |
1.4.1 | 121 | 8/13/2024 |
1.4.0 | 115 | 8/12/2024 |
1.3.6 | 112 | 8/9/2024 |
1.3.5 | 106 | 8/9/2024 |
1.3.4 | 105 | 8/9/2024 |
1.3.3 | 115 | 8/9/2024 |
1.3.2 | 83 | 8/6/2024 |
1.3.1 | 84 | 8/6/2024 |
1.3.0 | 74 | 8/6/2024 |
1.2.15 | 124 | 6/20/2024 |
1.2.14 | 122 | 6/20/2024 |
1.2.13 | 195 | 3/12/2024 |
1.2.12 | 179 | 3/12/2024 |
1.2.11 | 270 | 2/22/2024 |
1.2.10 | 234 | 2/20/2024 |
1.2.9 | 310 | 1/24/2024 |
1.2.8 | 308 | 1/24/2024 |
1.2.7 | 304 | 1/24/2024 |
1.2.6 | 280 | 1/22/2024 |
1.2.5 | 297 | 1/22/2024 |
1.2.4 | 321 | 1/22/2024 |
1.2.3 | 322 | 1/22/2024 |
1.2.2 | 274 | 1/22/2024 |
Added optional max child-pool queue length.
Reworked child thread pool exception handling, they are now thrown if not handled by the thread delegate.
Fix for expired child workers.
Optimization for completed child worker threads.
Added completion decrementers to other child pool overrides.
Added completion parameter.