Class TasksManager<TResult>
- Namespace
- Common
- Assembly
- Lykke.Common.dll
Helps working with a collection of tasks and perform group operations with them.
public sealed class TasksManager<TResult>
Type Parameters
TResult
A result type
- Inheritance
-
TasksManager<TResult>
- Inherited Members
- Extension Methods
Constructors
TasksManager()
public TasksManager()
Methods
Add(object, CancellationToken)
Creates a new task and add it into the internal collection
public Task<TResult> Add(object key, CancellationToken cancellationToken = default)
Parameters
key
objectA key
cancellationToken
CancellationTokenAn optional cancellation token. Can be used to set the task into the canceled state
Returns
- Task<TResult>
The created task
Cancel(object, CancellationToken)
Attempts to transition the task into the Canceled state.
public void Cancel(object key, CancellationToken cancellationToken = default)
Parameters
key
objectA key of the task
cancellationToken
CancellationTokenOptional cancellation token
CancelAll(CancellationToken)
Attempts to transition all tasks into the Canceled state.
public void CancelAll(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAn optional cancellation token
SetExceptionsToAll(Exception)
Attempts to transition all tasks into the Faulted state.
public void SetExceptionsToAll(Exception exception)
Parameters
exception
ExceptionAn
exception
to set in to task
SetResult(object, TResult)
Attempts to transition the task into the RanToCompletion state.
public void SetResult(object key, TResult result)
Parameters
key
objectThe task key
result
TResultThe
result
to set into the task