https://github.com/shuttle/shuttle.core.threading
Thread-based processing.
https://github.com/shuttle/shuttle.core.threading
Last synced: about 1 month ago
JSON representation
Thread-based processing.
- Host: GitHub
- URL: https://github.com/shuttle/shuttle.core.threading
- Owner: Shuttle
- License: bsd-3-clause
- Created: 2018-01-02T15:29:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-05T15:10:30.000Z (10 months ago)
- Last Synced: 2024-10-05T16:48:44.741Z (8 months ago)
- Language: C#
- Size: 139 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shuttle.Core.Threading
```
PM> Install-Package Shuttle.Core.Threading
```Provides various classes and interfaces to facilitate thread-based processing.
## ProcessorThreadPool
``` c#
public ProcessorThreadPool(
string name,
int threadCount,
IServiceScopeFactory serviceScopeFactory,
IProcessorFactory processorFactory,
ProcessorThreadOptions processorThreadOptions
);
```Each thread pool has a `name` used only for identyfing the pool. The `threadCount` determines the number of `ProcessorThread` instances in the pool. Each `ProcessorThread` calls the `IProcessor.ExecuteAsync(CancellationToken)` method on the instance provided by the `IProcessorFactory.Create()` method in a loop while the `CancellationToken.IsCancellationRequested` returns `false`.
Every call to `IProcessor.ExecuteAsync(ProcessorThreadContext, CancellationToken)` is wrapped in a `ProcessorThreadContext` instance that provides the `State` along with the `IServiceScope` instance created by the `IServiceScopeFactory.CreateScope()` method.
## ProcessorThreadOptions
| Option | Default | Description |
| --- | --- | --- |
| `JoinTimeout` | `00:00:15` | The duration to allow the processor thread to join the main thread. |
| `IsBackground` | `true` | Indicates whether the thread will be started as a background thread. Background threads are instantly killed when the host process stops. |
| `Priority` | `ThreadPriority.Normal` | Indicates the [thread priority](https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.priority?view=net-6.0). |