Class ForEachTask
Provides a static factory method for ForEachTask<T> as an alternative to calling the constructor to exploit type inference.
public static class ForEachTask
- Inheritance
-
objectForEachTask
Methods
Create<T>(string, IEnumerable<T>, Action<T>, Action<T>?)
Creates a new task that executes an action once for each element of a collection.
public static ForEachTask<T> Create<T>(string name, IEnumerable<T> target, Action<T> action, Action<T>? rollback = null)
Parameters
name
stringA name describing the task in human-readable form.
target
IEnumerable<T>A list of objects to execute the action for. Cancellation is possible between any two elements.
action
Action<T>The action to be executed once per element in
target
.rollback
Action<T>An optional action to try to undo changes made by
action
in case one of the invocations failed or the task was cancelled. Called once for each element for whichaction
was called (even if it failed), in reverse order. Any exceptions thrown here are logged and then ignored.
Returns
- ForEachTask<T>
Type Parameters
T