src/Azos/DisposableObject.cs
/// <summary>
/// Checks to see if the IDisposable reference is not null and sets it to null in a thread-safe way then calls Dispose().
/// Returns false if it is already null or not the original reference
/// </summary>
Checks to see if the IDisposable reference is not null and sets it to null in a thread-safe way then calls Dispose().
Returns false if it is already null or not the original reference
Checks to see if the IDisposable reference is not null and sets it to null in a thread - safe way then calls Dispose () . Returns false if it is already null or not the original reference
public static bool DisposeAndNull<T>(ref T obj) where T : class, IDisposable
      {
        var original = obj;
        var was = Interlocked.CompareExchange(ref obj, null, original);
        if (was==null || !object.ReferenceEquals(was, original)) return false;
        was.Dispose();
        return true;
      }
public static bool DisposeAndNull < T > ( ref T obj ) where T : class , IDisposable { var original = obj ; var was = Interlocked . CompareExchange ( ref obj , null , original ) ; if ( was == null || ! object . ReferenceEquals ( was , original ) ) return false ; was . Dispose ( ) ; return true ; }
Checks to see if the IDisposable reference is not null and sets it to null in a thread-safe way then calls Dispose().
Checks to see if the IDisposable reference is not null and sets it to null in a thread - safe way then calls Dispose () .
T
ref