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
namestringA name describing the task in human-readable form.
targetIEnumerable<T>A list of objects to execute the action for. Cancellation is possible between any two elements.
actionAction<T>The action to be executed once per element in
target.rollbackAction<T>An optional action to try to undo changes made by
actionin case one of the invocations failed or the task was cancelled. Called once for each element for whichactionwas called (even if it failed), in reverse order. Any exceptions thrown here are logged and then ignored.
Returns
- ForEachTask<T>
Type Parameters
T