protected override void Dispose(bool disposing) { if (!disposing) { return; } if (RegisteredInstances == null) { return; } lock (RegisteredInstances) { foreach (var o in RegisteredInstances.Values) { foreach (var r in o) { IJavaPeerable t; if (!r.TryGetTarget(out t)) { continue; } t.Dispose(); } } RegisteredInstances.Clear(); } }
protected override void Dispose(bool disposing) { try { if (!disposing) { return; } if (RegisteredInstances == null) { return; } lock (RegisteredInstances) { var refs = RegisteredInstances.Values .SelectMany(e => e) .ToList(); foreach (var r in refs) { if (r.TryGetTarget(out var t)) { t.Dispose(); } } RegisteredInstances.Clear(); RegisteredInstances = null; } } finally { base.Dispose(disposing); } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (!disposing) { return; } if (RegisteredInstances == null) { return; } lock (RegisteredInstances) { foreach (var o in RegisteredInstances.Values) { foreach (var r in o) { IJavaPeerable t; if (!r.TryGetTarget(out t)) { continue; } t.Dispose(); } } RegisteredInstances.Clear(); RegisteredInstances = null; } if (bridge != IntPtr.Zero) { NativeMethods.java_interop_gc_bridge_remove_current_app_domain(bridge); bridge = IntPtr.Zero; } }