Table of Contents

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

bool

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

asyncDisposable T

The 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

disposalAction Action

The 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

disposalTask Func<Task>

The disposal task

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

disposable T

The 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