Skip to main content

Class DisposeSafety

Utilities for disposing stuff.

Assembly: Dalamud.dll
View Source
Declaration
public static class DisposeSafety

Methods

ToDisposableIgnoreExceptions<T>(Task<T>)

Returns a proxy System.IDisposable that on dispose will dispose the result of the given System.Threading.Tasks.Task%601.

If any exception has occurred, it will be ignored.

View Source
Declaration
public static IDisposable ToDisposableIgnoreExceptions<T>(this Task<T> task) where T : IDisposable
Returns

System.IDisposable: The proxy System.IDisposable.

Parameters
TypeNameDescription
System.Threading.Tasks.Task<<T>>taskThe task.
Type Parameters
NameDescription
TA disposable type.

ToContentDisposedTask<T>(Task<T>, bool)

Transforms <code class="paramref">task</code> into a System.Threading.Tasks.Task, disposing the content as necessary.

View Source
Declaration
public static Task ToContentDisposedTask<T>(this Task<T> task, bool ignoreAllExceptions = false) where T : IDisposable
Returns

System.Threading.Tasks.Task: A wrapper for the task.

Parameters
TypeNameDescription
System.Threading.Tasks.Task<<T>>taskThe task.
System.BooleanignoreAllExceptionsIgnore all exceptions.
Type Parameters
NameDescription
TA disposable type.

AggregateToDisposable<T>(IEnumerable<T>?)

Returns a proxy System.IDisposable that on dispose will dispose all the elements of the given System.Collections.Generic.IEnumerable%601 of <code class="typeparamref">T</code>s.

View Source
Declaration
public static IDisposable AggregateToDisposable<T>(this IEnumerable<T>? disposables) where T : IDisposable
Returns

System.IDisposable: The proxy System.IDisposable.

Parameters
TypeNameDescription
System.Collections.Generic.IEnumerable<<T>>disposablesThe disposables.
Type Parameters
NameDescription
TThe disposable types.
Exceptions

System.AggregateException
Error.