Show / Hide Table of Contents

Class Disposable

Provides implementation of dispose pattern.

Inheritance
object
Disposable
BufferWriter<T>
SparseBufferWriter<T>
FileReader
FileWriter
ReadOnlySequenceAccessor
MemoryTransferObject
StreamTransferObject
CommandInterpreter
ConsensusOnlyState
RaftClusterHttpHost
ClusterConfigurationStorage<TAddress>
MemoryBasedStateMachine.SnapshotBuilder
PersistentState
RaftClusterMember
RaftCluster<TMember>
WriteAheadLog
PeerController
DiskSpacePool
RandomAccessCache<TKey, TValue>
ValueTupleBuilder
AsyncBarrier
AsyncExchanger<T>
LeaseConsumer
LeaseProvider<TMetadata>
QueuedSynchronizer
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public abstract class Disposable : IDisposable

Properties

| Edit this page View Source

DisposedTask

Gets a task representing ObjectDisposedException exception.

Declaration
protected Task DisposedTask { get; }
Property Value
Type Description
Task
| Edit this page View Source

IsDisposed

Indicates that this object is disposed.

Declaration
protected bool IsDisposed { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsDisposing

Indicates that DisposeAsync() is called but not yet completed.

Declaration
protected bool IsDisposing { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsDisposingOrDisposed

Indicates that DisposeAsync() is called.

Declaration
protected bool IsDisposingOrDisposed { get; }
Property Value
Type Description
bool

Methods

| Edit this page View Source

CreateException()

Creates a new instance of ObjectDisposedException class.

Declaration
protected ObjectDisposedException CreateException()
Returns
Type Description
ObjectDisposedException

A new instance of the exception that can be thrown by the caller.

| Edit this page View Source

Dispose()

Releases all resources associated with this object.

Declaration
public void Dispose()
| Edit this page View Source

Dispose(bool)

Releases managed and unmanaged resources associated with this object.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

true if called from Dispose(); false if called from finalizer ~Disposable().

| Edit this page View Source

Dispose(IEnumerable<IDisposable?>)

Disposes many objects.

Declaration
public static void Dispose(IEnumerable<IDisposable?> objects)
Parameters
Type Name Description
IEnumerable<IDisposable> objects

An array of objects to dispose.

| Edit this page View Source

DisposeAsync()

Releases managed resources associated with this object asynchronously.

Declaration
protected ValueTask DisposeAsync()
Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Remarks

If derived class implements IAsyncDisposable then DisposeAsync() can be trivially implemented through delegation of the call to this method.

| Edit this page View Source

DisposeAsync(IEnumerable<IAsyncDisposable?>)

Disposes many objects.

Declaration
public static ValueTask DisposeAsync(IEnumerable<IAsyncDisposable?> objects)
Parameters
Type Name Description
IEnumerable<IAsyncDisposable> objects

An array of objects to dispose.

Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

| Edit this page View Source

DisposeAsync(params IAsyncDisposable?[])

Disposes many objects in safe manner.

Declaration
public static ValueTask DisposeAsync(params IAsyncDisposable?[] objects)
Parameters
Type Name Description
IAsyncDisposable[] objects

An array of objects to dispose.

Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

| Edit this page View Source

DisposeAsyncCore()

Releases managed resources associated with this object asynchronously.

Declaration
protected virtual ValueTask DisposeAsyncCore()
Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Remarks

This method makes sense only if derived class implements IAsyncDisposable interface.

| Edit this page View Source

Dispose<T>(ReadOnlySpan<T>)

Disposes many objects in safe manner.

Declaration
public static void Dispose<T>(ReadOnlySpan<T> objects) where T : IDisposable?
Parameters
Type Name Description
ReadOnlySpan<T> objects

An array of objects to dispose.

Type Parameters
Name Description
T
| Edit this page View Source

~Disposable()

Finalizes this object.

Declaration
protected ~Disposable()
| Edit this page View Source

GetDisposedTask<T>()

Returns a task representing ObjectDisposedException exception.

Declaration
protected Task<T> GetDisposedTask<T>()
Returns
Type Description
Task<T>

The task representing ObjectDisposedException exception.

Type Parameters
Name Description
T

The type of the task.

| Edit this page View Source

TryBeginDispose()

Starts disposing this object.

Declaration
protected bool TryBeginDispose()
Returns
Type Description
bool

true if cleanup operations can be performed; false if the object is already disposing.

| Edit this page View Source

TrySetDisposedException(TaskCompletionSource)

Attempts to complete the task with ObjectDisposedException exception.

Declaration
protected bool TrySetDisposedException(TaskCompletionSource source)
Parameters
Type Name Description
TaskCompletionSource source

The task completion source.

Returns
Type Description
bool

true if operation was successful; otherwise, false.

| Edit this page View Source

TrySetDisposedException<T>(TaskCompletionSource<T>)

Attempts to complete the task with ObjectDisposedException exception.

Declaration
protected bool TrySetDisposedException<T>(TaskCompletionSource<T> source)
Parameters
Type Name Description
TaskCompletionSource<T> source

The task completion source.

Returns
Type Description
bool

true if operation was successful; otherwise, false.

Type Parameters
Name Description
T

The type of the task.

Implements

IDisposable

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)

See Also

IDisposable
IAsyncDisposable
Implementing Dispose method
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾