public object GetNativeObject(long id, bool addGC) { if (this.ParentControlId == id) { return(this.GetParentControl()); } if (NativeObjectInfoDic.ContainsKey(id)) { if (addGC) { NativeObjectInfoDic[id].GcInfo++; } return(NativeObjectInfoDic[id].RealObject); } return(null); }
public void DestroyNativeObject(long id, bool isGC) { if (NativeObjectInfoDic.ContainsKey(id)) { var obj = NativeObjectInfoDic[id]; if (isGC) { obj.GcInfo--; } else { obj.GcInfo = 0; } if (obj.GcInfo == 0) { this.NativeObjectInfoDic.Remove(id); if (obj.RealObject is IDisposable) { var disposableObj = obj.RealObject as IDisposable; disposableObj.Dispose(); } } } }