Class TaskRegistry
Represents an object useful for storing in-progress Task instances.
public sealed class TaskRegistry : IDisposable, IAsyncDisposable
- Inheritance
-
TaskRegistry
- Implements
- Inherited Members
- Extension Methods
Constructors
TaskRegistry()
Creates a new empty TaskRegistry instance.
public TaskRegistry()
Properties
Count
Returns the current amount of stored in-progress Task instances.
public int Count { get; }
Property Value
Methods
Add(Task)
Registers provided task in this registry and stores it until it gets completed.
Does nothing when task is already completed.
public void Add(Task task)
Parameters
Remarks
Task continuation that is responsible for removing provided task from this registry once it gets completed
is created with the ExecuteSynchronously option.
Exceptions
- ObjectDisposedException
When this registry has been disposed.
- ArgumentException
When TaskStatus of
taskis equal to Created.
Contains(Task)
Checks if the provided task is currently stored by this registry.
[Pure]
public bool Contains(Task task)
Parameters
taskTaskTask to check for.
Returns
- bool
true when
taskis currently stored by this registry, otherwise false.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Remarks
Marks this registry as disposed and waits for all stored in-progress Task instances to complete.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
Remarks
Marks this registry as disposed and returns a ValueTask that waits for all stored in-progress Task instances to complete.
WaitForAll()
Creates a new Task that allows to wait for completion of all currently stored tasks in this registry.
[Pure]
public Task WaitForAll()
Returns
- Task
Task instance that allows to wait for completion of all currently stored tasks in this registry.
Remarks
Tasks added to this registry after this method invocation will not be dynamically appended to the returned task. See WhenAll(params Task[]) for more information.