public unsafe static CefImage Wrap(Func <IntPtr, CefImage> create, cef_image_t *instance) { if (instance == null) { return(null); } IntPtr key = new IntPtr(instance); lock (WeakRefs) { CefImage wrapper; foreach (WeakReference <CefImage> weakRef in WeakRefs) { if (weakRef.TryGetTarget(out wrapper)) { if (wrapper._instance == key || instance->IsSame(wrapper.GetNativeInstance()) != 0) { instance->@base.Release(); return(wrapper); } } } wrapper = CefBaseRefCounted <cef_image_t> .Wrap(create, instance); WeakRefs.Add(wrapper.WeakRef); return(wrapper); } }
public int Release() { int count; lock (this) { count = --_count; if (count == 0) { Root = null; } } return(count); }
public int Release() { int count; ICriticalRefCounted critical = null; lock (this) { count = --_count; if (count == 0) { critical = Root as ICriticalRefCounted; Root = null; } } critical?.Dispose(); return(count); }
public void AddRef() { lock (this) { _count++; if (_count == 1) { if (Instance.TryGetTarget(out CefBaseRefCounted instance)) { Root = instance; } else { throw new InvalidCefObjectException(); } } } }
/// <summary> /// Sets the user data for this object and returns true (1) on success. Returns /// false (0) if this function is called incorrectly. This function can only be /// called on user created objects. /// </summary> public unsafe virtual bool SetUserData(CefBaseRefCounted userData) { return(SafeCall(NativeInstance->SetUserData(userData.GetNativeInstance()) != 0)); }