Method SafeDisposeSuppressException
SafeDisposeSuppressException<T>(ref T?)
Safely disposes of the specified disposable object, suppressing any exceptions that occur during disposal.
public static void SafeDisposeSuppressException<T>(ref T? disposable) where T : IDisposable
Parameters
disposableTA reference to the disposable object to be disposed. The reference is set to null after disposal.
Type Parameters
TThe type of the disposable object, which must implement IDisposable.
Remarks
This method ensures that the disposal of the object does not propagate exceptions, which can be useful in scenarios where disposal failures should not disrupt the execution flow. Any exceptions encountered during disposal are logged using WriteLine(string).