Class Disposable
Provides implementation of dispose pattern.
Inheritance
Implements
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
[BeforeFieldInit(true)]
public abstract class Disposable : IDisposable
  Properties
| Improve this Doc View SourceDisposedTask
Gets a task representing ObjectDisposedException exception.
Declaration
protected Task DisposedTask { get; }
  Property Value
| Type | Description | 
|---|---|
| Task | 
IsDisposed
Indicates that this object is disposed.
Declaration
protected bool IsDisposed { get; }
  Property Value
| Type | Description | 
|---|---|
| Boolean | 
Methods
| Improve this Doc View SourceDispose()
Releases all resources associated with this object.
Declaration
public void Dispose()
  Dispose(Boolean)
Releases managed and unmanaged resources associated with this object.
Declaration
protected virtual void Dispose(bool disposing)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Boolean | disposing | true if called from Dispose(); false if called from finalizer Finalize().  | 
      
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.  | 
      
Dispose(IDisposable[])
Disposes many objects in safe manner.
Declaration
public static void Dispose(params IDisposable[] objects)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IDisposable[] | objects | An array of objects to dispose.  | 
      
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.  | 
      
DisposeAsync(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.  | 
      
Finalize()
Finalizes this object.
Declaration
protected void Finalize()
  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.  | 
      
QueueDispose(IDisposable)
Places Dispose() method call into thread pool.
Declaration
protected static void QueueDispose(IDisposable resource)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IDisposable | resource | The resource to be disposed.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | 
  | 
      
ThrowIfDisposed()
Throws exception if this object is disposed.
Declaration
protected void ThrowIfDisposed()
  Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Object is disposed.  | 
      
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 | 
|---|---|
| Boolean | true if operation was successful; otherwise, false.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of the task.  |