Class DisposableManager
- Namespace
- SharpConsoleUI.Core
- Assembly
- SharpConsoleUI.dll
Manager for tracking and disposing resources in a coordinated manner
public sealed class DisposableManager : IDisposable, IAsyncDisposable
- Inheritance
-
DisposableManager
- Implements
- Inherited Members
- Extension Methods
Constructors
DisposableManager()
Initializes a new instance of the DisposableManager class
public DisposableManager()
Properties
IsDisposed
Gets whether the manager has been disposed
public bool IsDisposed { get; }
Property Value
Methods
CreateScope()
Creates a disposal scope that will be automatically registered
public DisposalScope CreateScope()
Returns
- DisposalScope
A disposal scope
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
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.
RegisterAsync<T>(T)
Registers an async disposable resource for management
public T RegisterAsync<T>(T asyncDisposable) where T : IAsyncDisposable
Parameters
asyncDisposableTThe async disposable resource
Returns
- T
The registered resource for fluent chaining
Type Parameters
T
Exceptions
- ObjectDisposedException
Thrown if the manager is already disposed
- ArgumentNullException
Thrown if asyncDisposable is null
RegisterDisposalAction(Action)
Registers a disposal action (synchronous)
public void RegisterDisposalAction(Action disposalAction)
Parameters
disposalActionActionThe disposal action
Exceptions
- ObjectDisposedException
Thrown if the manager is already disposed
RegisterDisposalTask(Func<Task>)
Registers a custom disposal task
public void RegisterDisposalTask(Func<Task> disposalTask)
Parameters
Exceptions
- ObjectDisposedException
Thrown if the manager is already disposed
Register<T>(T)
Registers a disposable resource for management
public T Register<T>(T disposable) where T : IDisposable
Parameters
disposableTThe disposable resource
Returns
- T
The registered resource for fluent chaining
Type Parameters
T
Exceptions
- ObjectDisposedException
Thrown if the manager is already disposed
- ArgumentNullException
Thrown if disposable is null