AsyncTaskFactoryOptions Class
Definition
- Assemblies
- Cuemon.Threading.dll
Configuration options for ParallelFactory.
public class AsyncTaskFactoryOptions : AsyncWorkloadOptions, IAsyncOptions, IParameterObject
- Inheritance
-
AsyncTaskFactoryOptions
- Implements
- Inherited Members
Examples
The following example demonstrates how to configure AsyncTaskFactoryOptions to control task creation options and scheduler when using AdvancedParallelFactory.For.
using System;
using System.Threading.Tasks;
using Cuemon;
using Cuemon.Threading;
namespace MyApp.Examples;
public class AsyncTaskFactoryOptionsExample
{
public void Demonstrate()
{
// Direct instantiation of AsyncTaskFactoryOptions
var factoryOptions = new AsyncTaskFactoryOptions
{
CreationOptions = TaskCreationOptions.None,
PartitionSize = 2
};
var rules = new ForLoopRuleset<int>(0, 10, 1);
AdvancedParallelFactory.For(rules, i =>
{
Console.WriteLine($"Processing item {i}");
}, o =>
{
o.CreationOptions = TaskCreationOptions.None;
o.Scheduler = TaskScheduler.Default;
o.PartitionSize = 2;
});
}
}
Constructors
| Name | Description |
|---|---|
| AsyncTaskFactoryOptions() | Initializes a new instance of the AsyncTaskFactoryOptions class. |
Properties
| Name | Description |
|---|---|
| CreationOptions | Gets or sets the TaskCreationOptions used to create the task. |
| Scheduler | Gets or sets the TaskScheduler that is used to schedule the task. |