internal void CreateNative(CfxApi.cfx_ctor_with_gc_handle_delegate cfx_ctor) { // must be a weak handle // otherwise transient callback structs never go out of scope if // they are not explicitly disposed System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(this, System.Runtime.InteropServices.GCHandleType.Weak); m_nativePtr = cfx_ctor(System.Runtime.InteropServices.GCHandle.ToIntPtr(handle)); if (m_nativePtr == IntPtr.Zero) { throw new OutOfMemoryException(); } }
internal CfxBaseClient(CfxApi.cfx_ctor_with_gc_handle_delegate cfx_ctor) { // must be a weak handle // otherwise transient callback structs never go out of scope if // they are not explicitly disposed GCHandle handle = GCHandle.Alloc(this, GCHandleType.Weak); var nativePtr = cfx_ctor(GCHandle.ToIntPtr(handle), 0); if (nativePtr == IntPtr.Zero) { throw new OutOfMemoryException(); } SetNative(nativePtr); }
internal CfxClientBase(CfxApi.cfx_ctor_with_gc_handle_delegate cfx_ctor) { CreateNative(cfx_ctor); }