Table of Contents

Class DisposableHelper

Namespace
Ecng.Common
Assembly
Ecng.Common.dll

Provides helper methods for creating and managing disposable objects.

public static class DisposableHelper
Inheritance
DisposableHelper
Inherited Members

Methods

DisposeAll(IEnumerable<IDisposable>)

Disposes all IDisposable objects in the enumerable.

public static void DisposeAll(this IEnumerable<IDisposable> disposables)

Parameters

disposables IEnumerable<IDisposable>

The enumerable of disposable objects.

Exceptions

ArgumentNullException

Thrown when disposables is null.

MakeDisposable<T>(T, Action<T>)

Creates a disposable object that performs the specified disposal action on the provided unmanaged data.

public static Disposable MakeDisposable<T>(this T unmanagedData, Action<T> disposeAction)

Parameters

unmanagedData T

The unmanaged data to be disposed.

disposeAction Action<T>

The action to execute during disposal.

Returns

Disposable

A disposable object that calls the disposal action.

Type Parameters

T

The type of the unmanaged data.