public void Close() { if (IsClosed) { return; } RuntimeHelpers.PrepareConstrainedRegions(); try { /* Close handle in a constrained execution region */ } finally { // Note we expect this call to also do explicit native close first rather than relying on destruction // in case other handles preserve pointers - they will no longer work but don't stop closing SharedRealmHandle.Close(); } }
private void Dispose(bool disposing) { if (IsClosed) { return; } if (disposing && !(SharedRealmHandle is UnownedRealmHandle)) { SharedRealmHandle.CloseRealm(); } SharedRealmHandle.Close(); // Note: this closes the *handle*, it does not trigger realm::Realm::close(). }
private void Dispose(bool disposing) { if (IsClosed) { throw new ObjectDisposedException(nameof(Realm)); } if (disposing && !(SharedRealmHandle is UnownedRealmHandle)) { SharedRealmHandle.CloseRealm(); } SharedRealmHandle.Close(); // Note: this closes the *handle*, it does not trigger realm::Realm::close(). if (stringGetBuffer != IntPtr.Zero) { Marshal.FreeHGlobal(stringGetBuffer); stringGetBuffer = IntPtr.Zero; stringGetBufferLen = 0; } }