A simple, easy-to-use lightweight, no-dependency library for executing an `Actionable<TRequest, TResult>` delegate N times. The library provides a way to balance the number of iterations requested by delegating a specific amount of iterations per thread on your machine supporting cancellation tokens per iteration.
$ dotnet add package TaskRipper.CoreA library for executing delegates N times, on multiple threads simplifying the balancing of work for each thread, and supporting CancellationTokens.
The delegate supported is Actionable<TRequest, TResult> which has a generic input parameter and output return type.
A simple, easy-to-use lightweight, no-dependency library for executing an Actionable<TRequest, TResult> delegate N times.
The library provides a way to balance the number of iterations requested by delegating a specific amount of iterations per thread on your machine supporting cancellation tokens per iteration.
The intention of the library is ease of use, so this is the minimal code to execute a task.
Included is creating the IWorkExecutor instance which can be injected via constructor.
In two lines essentially, you're able to execute a task.
var contract = new WorkContractBuilder()
.WithIterations(100000)
.WithCancellationToken(CancellationToken.None) // Optional line, the system will consider empty tokens and disregard them in execution.
.WithWorkBalancingOptions(WorkBalancerOptions.Optimize)
.UseDefaultExecutionSettings() // Can provide your own. Most classes have a Default static property for easy access to default objects.
.Build();
var workResult = await WorkExecutor.Default.ExecuteAsync(contract, ActionableString, request);
private string ActionableString(int request)
{
return request.ToString();
}
Replace the ActionableString function with another one of your choosing to support any return type + any input type.