Class DisposableExtensions
- Namespace
- FinanceSharp
- Assembly
- FinanceSharp.dll
Provides extensions methods for IDisposable
public static class DisposableExtensions
- Inheritance
-
DisposableExtensions
- Inherited Members
Methods
DisposeSafely(IDisposable)
Calls Dispose() within a try/catch and logs any errors.
public static bool DisposeSafely(this IDisposable disposable)
Parameters
disposableIDisposableThe IDisposable to be disposed
Returns
- bool
True if the object was successfully disposed, false if an error was thrown
DisposeSafely(IDisposable, Action<Exception>)
Calls <xref href="System.IDisposable.Dispose" data-throw-if-not-resolved="false"></xref> within a try/catch and invokes the
errorHandler on any errors.
public static bool DisposeSafely(this IDisposable disposable, Action<Exception> errorHandler)
Parameters
disposableIDisposableThe IDisposable to be disposed
errorHandlerAction<Exception>Error handler delegate invoked if an exception is thrown while calling Dispose()
Returns
- bool
True if the object was successfully disposed, false if an error was thrown or the specified disposable was null