public TextureContent(GraphicsDevice graphicsDevice, bool generateMipMaps, int mipMapCount, byte[] inputData, int width, int height, TextureContentFormat inputFormat, TextureContentFormat outputFormat) { this.graphicsDevice = graphicsDevice; System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(inputData, System.Runtime.InteropServices.GCHandleType.Pinned); createTexture(generateMipMaps, mipMapCount, handle.AddrOfPinnedObject(), width, height, inputFormat, outputFormat); handle.Free(); }
protected override void EnqueueWrite(CallContext CallContext, int i, long ElementCount, OpenCLNet.MemFlags MemFlags) { Type RealElementType = Value.GetType().GetElementType(); int ElementSize = System.Runtime.InteropServices.Marshal.SizeOf(RealElementType); #if USE_HOST_POINTER m_GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(Value, System.Runtime.InteropServices.GCHandleType.Pinned); MemBuffer = CallContext.Context.CreateBuffer(MemFlags | OpenCLNet.MemFlags.USE_HOST_PTR, ElementCount * ElementSize, m_GCHandle.Value.AddrOfPinnedObject()); CallContext.Kernel.SetArg(i, MemBuffer); #else MemBuffer = CallContext.Context.CreateBuffer(MemFlags, ElementCount * ElementSize, IntPtr.Zero); CallContext.Kernel.SetArg(i, MemBuffer); // // If the buffer is read by the device, transfer the data // if (m_ForRead) { System.Runtime.InteropServices.GCHandle gch = System.Runtime.InteropServices.GCHandle.Alloc(Value, System.Runtime.InteropServices.GCHandleType.Pinned); try { IntPtr p = gch.Value.AddrOfPinnedObject(); CallContext.CommandQueue.EnqueueWriteBuffer(MemBuffer, true, IntPtr.Zero, new IntPtr(ElementCount * ElementSize), p); } finally { gch.Free(); } } #endif }
public unsafe static T[] Create <T>(void *source, int length) { System.Type type = typeof(T); int sizeInBytes = System.Runtime.InteropServices.Marshal.SizeOf(type); T[] output = new T[length]; if (type.IsPrimitive) { // Make sure the array won't be moved around by the GC System.Runtime.InteropServices.GCHandle handleOutput = default(System.Runtime.InteropServices.GCHandle); try { handleOutput = System.Runtime.InteropServices.GCHandle.Alloc(output, System.Runtime.InteropServices.GCHandleType.Pinned); int byteLength = length * sizeInBytes; // There are faster ways to do this, particularly by using wider types or by // handling special lengths. //for (int i = 0; i < byteLength; i++) // destination[i] = ((byte*)source)[i]; //E,g, like this... the problem is that handle doesn't point to the array elements... //Could instead give a T[] source or IntPtr. System.Buffer.MemoryCopy(source, (void *)handleOutput.AddrOfPinnedObject(), byteLength, byteLength); } finally { if (handleOutput.IsAllocated) { handleOutput.Free(); } } } else if (type.IsValueType) { if (false == type.IsLayoutSequential && false == type.IsExplicitLayout) { throw new System.InvalidOperationException(string.Format("{0} does not define a StructLayout attribute", type)); } System.IntPtr sourcePtr = new System.IntPtr(source); for (int i = 0; i < length; i++) { System.IntPtr p = new System.IntPtr((byte *)source + i * sizeInBytes); output[i] = (T)System.Runtime.InteropServices.Marshal.PtrToStructure(p, typeof(T)); } } else { throw new System.InvalidOperationException(string.Format("{0} is not supported", type)); } return(output); }
private void __EventCleanup() { { Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Windows_Kinect_KinectSensor_add_IsAvailableChanged(_pNative, Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handler, true); } _Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handle.Free(); } } } { Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Windows_Kinect_KinectSensor_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); } _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); } } } }
private static int LuaMetaCachedGC(IntPtr l) { IntPtr pud = l.touserdata(1); IntPtr hval = System.Runtime.InteropServices.Marshal.ReadIntPtr(pud); System.Runtime.InteropServices.GCHandle handle = new System.Runtime.InteropServices.GCHandle(); object obj = null; try { handle = (System.Runtime.InteropServices.GCHandle)hval; obj = handle.Target; } catch { } if (obj != null) { var cache = LuaObjCache.GetObjCache(l); if (cache != null) { cache.Remove(obj); } } try { handle.Free(); } catch { } return(0); }
private void __EventCleanup() { { Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Windows_Kinect_LongExposureInfraredFrameReader_add_FrameArrived(_pNative, Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handler, true); } _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handle.Free(); } } } { Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Windows_Kinect_LongExposureInfraredFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); } _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); } } } }
private Mogre.Image SystemtoMogreImage(System.Drawing.Image image) { Stream oStream = new MemoryStream(); image.Save(oStream, System.Drawing.Imaging.ImageFormat.Png); /* Back to the start of the stream */ oStream.Position = 0; /* read all the stream in a buffer */ BinaryReader oBinaryReader = new BinaryReader(oStream); byte[] pBuffer = oBinaryReader.ReadBytes((int)oBinaryReader.BaseStream.Length); oStream.Close(); /*No more needed */ Mogre.Image oMogreImage = new Mogre.Image(); unsafe { System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(pBuffer, System.Runtime.InteropServices.GCHandleType.Pinned); byte *pUnsafeByte = (byte *)handle.AddrOfPinnedObject(); void *pUnsafeBuffer = (void *)handle.AddrOfPinnedObject(); MemoryDataStream oMemoryStream = new MemoryDataStream(pUnsafeBuffer, (uint)pBuffer.Length); DataStreamPtr oPtrDataStream = new DataStreamPtr(oMemoryStream); oMogreImage = oMogreImage.Load(oPtrDataStream, "png"); handle.Free(); } return(oMogreImage); }
private void __EventCleanup() { { Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameArrivedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameReader_add_FrameArrived(_pNative, Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameArrivedEventArgs_Delegate_Handler, true); } _Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameArrivedEventArgs_Delegate_Handle.Free(); } } } { Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); } _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); } } } }
public Packet.PacketHeader ByteArrayToNewStuff(byte[] bytes) { System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(bytes, System.Runtime.InteropServices.GCHandleType.Pinned); Packet.PacketHeader stuff = (Packet.PacketHeader)System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Packet.PacketHeader)); handle.Free(); return(stuff); }
public override void SetData <T>(T[] data, int startIndex, int elementCount) { if (_usage == VertexBufferUsage.Static) { throw new Exception("Can't update a vertex buffer created as Static"); } GL.GetError(); GL.BindBuffer(BufferTarget.ArrayBuffer, _buffer); System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try { IntPtr pointer = handle.AddrOfPinnedObject(); int size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(elementCount * size), Gk3Main.Utils.IncrementIntPtr(pointer, size * startIndex), (BufferUsageHint)convertUsage(_usage)); } finally { if (handle.IsAllocated) { handle.Free(); } } GlException.ThrowExceptionIfErrorExists(); }
private void __EventCleanup() { { Microsoft_Kinect_Face_TrackingIdLostEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Microsoft_Kinect_Face_TrackingIdLostEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Microsoft_Kinect_Face_FaceFrameSource_add_TrackingIdLost(_pNative, Microsoft_Kinect_Face_TrackingIdLostEventArgs_Delegate_Handler, true); } _Microsoft_Kinect_Face_TrackingIdLostEventArgs_Delegate_Handle.Free(); } } } { Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Microsoft_Kinect_Face_FaceFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); } _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); } } } }
public virtual void WriteArray(byte[] data, uint length) { System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try { { SharingClientPINVOKE.NetworkOutMessage_WriteArray(swigCPtr, (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), length); } } finally { pinHandle_data.Free(); } }
/// <summary> /// 清除記憶體 /// </summary> private void Clear(string sSecretKey) { // For additional security Pin the key. System.Runtime.InteropServices.GCHandle Gch = System.Runtime.InteropServices.GCHandle.Alloc(sSecretKey, System.Runtime.InteropServices.GCHandleType.Pinned); // Remove the Key from memory. ZeroMemory(Gch.AddrOfPinnedObject(), sSecretKey.Length * 2); Gch.Free(); }
/// <summary> /// 获取字符串的地址位 /// </summary> /// <param name="e"></param> /// <returns></returns> int VarPtr(object e) { System.Runtime.InteropServices.GCHandle gh = System.Runtime.InteropServices.GCHandle.Alloc(e, System.Runtime.InteropServices.GCHandleType.Pinned); int gc = gh.AddrOfPinnedObject().ToInt32(); gh.Free(); return(gc); }
public virtual void CopyImageData(byte[] data, int bufferSize, int bytesPerPixel) { System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try { { SharingClientPINVOKE.TagImage_CopyImageData(swigCPtr, (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), bufferSize, bytesPerPixel); } } finally { pinHandle_data.Free(); } }
String ExampleWithStream() { //Initilaizing MediaInfo MediaInfo MI = new MediaInfo(); //From: preparing an example file for reading FileStream From = new FileStream("Example.ogg", FileMode.Open, FileAccess.Read); //From: preparing a memory buffer for reading byte[] From_Buffer = new byte[64 * 1024]; int From_Buffer_Size; //The size of the read file buffer //Preparing to fill MediaInfo with a buffer MI.Open_Buffer_Init(From.Length, 0); //The parsing loop do { //Reading data somewhere, do what you want for this. From_Buffer_Size = From.Read(From_Buffer, 0, 64 * 1024); //Sending the buffer to MediaInfo System.Runtime.InteropServices.GCHandle GC = System.Runtime.InteropServices.GCHandle.Alloc(From_Buffer, System.Runtime.InteropServices.GCHandleType.Pinned); IntPtr From_Buffer_IntPtr = GC.AddrOfPinnedObject(); if (MI.Open_Buffer_Continue(From_Buffer_IntPtr, (IntPtr)From_Buffer_Size) == 0) //Note: How to provide a buffer[]? { GC.Free(); break; } GC.Free(); //Testing if MediaInfo request to go elsewhere if (MI.Open_Buffer_Continue_GoTo_Get() != -1) { Int64 Position = From.Seek(MI.Open_Buffer_Continue_GoTo_Get(), SeekOrigin.Begin); //Position the file MI.Open_Buffer_Init(From.Length, Position); //Informing MediaInfo we have seek } }while (From_Buffer_Size > 0); //Finalizing MI.Open_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work //Get() example return(MI.Get(StreamKind.General, 0, "Format")); }
public void Dispose() { if (!disposed) { handle.Free(); ptr = IntPtr.Zero; disposed = true; } }
public virtual bool GetData(byte[] data, int dataSize) { System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try { { bool ret = SharingClientPINVOKE.AnchorDownloadRequest_GetData(swigCPtr, (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), dataSize); return(ret); } } finally { pinHandle_data.Free(); } }
public virtual bool UploadAnchor(Room room, XString anchorName, byte[] data, int dataSize) { System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try { { bool ret = SharingClientPINVOKE.RoomManager_UploadAnchor(swigCPtr, Room.getCPtr(room), XString.getCPtr(anchorName), (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), dataSize); return(ret); } } finally { pinHandle_data.Free(); } }
public void UnpinData() { if (m_PinnedHandle == default(System.Runtime.InteropServices.GCHandle)) { return; } m_PinnedHandle.Free(); m_PinnedHandle = default(System.Runtime.InteropServices.GCHandle); }
private void OnDestroy() { if (ms_pInMemoryBankPtr != System.IntPtr.Zero) { var result = AkSoundEngine.UnloadBank(ms_bankID, ms_pInMemoryBankPtr); if (result == AKRESULT.AK_Success) ms_pinnedArray.Free(); } }
public virtual bool ProcessImage(byte[] image, int width, int height, int bytesPerPixel) { System.Runtime.InteropServices.GCHandle pinHandle_image = System.Runtime.InteropServices.GCHandle.Alloc(image, System.Runtime.InteropServices.GCHandleType.Pinned); try { { bool ret = SharingClientPINVOKE.VisualPairConnector_ProcessImage(swigCPtr, (System.IntPtr)pinHandle_image.AddrOfPinnedObject(), width, height, bytesPerPixel); return(ret); } } finally { pinHandle_image.Free(); } }
Action WrapContinuation(Action continuation) { Action wrapper = () => { _gcHandle.Free(); continuation(); }; _gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(wrapper); return wrapper; }
/// <summary> /// /// </summary> public override void Dispose() { Debugger?.Dispose(); Debugger = null; Instance?.Dispose(); Instance = null; gch_.Free(); }
private System.Collections.IEnumerator LoadFile() { ms_www = new UnityEngine.WWW(m_bankPath); yield return(ms_www); uint in_uInMemoryBankSize = 0; // Allocate an aligned buffer try { ms_pinnedArray = System.Runtime.InteropServices.GCHandle.Alloc(ms_www.bytes, System.Runtime.InteropServices.GCHandleType.Pinned); ms_pInMemoryBankPtr = ms_pinnedArray.AddrOfPinnedObject(); in_uInMemoryBankSize = (uint)ms_www.bytes.Length; // Array inside the WWW object is not aligned. Allocate a new array for which we can guarantee the alignment. if ((ms_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0) { var alignedBytes = new byte[ms_www.bytes.Length + AK_BANK_PLATFORM_DATA_ALIGNMENT]; var new_pinnedArray = System.Runtime.InteropServices.GCHandle.Alloc(alignedBytes, System.Runtime.InteropServices.GCHandleType.Pinned); var new_pInMemoryBankPtr = new_pinnedArray.AddrOfPinnedObject(); var alignedOffset = 0; // New array is not aligned, so we will need to use an offset inside it to align our data. if ((new_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0) { var alignedPtr = (new_pInMemoryBankPtr.ToInt64() + AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) & ~AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK; alignedOffset = (int)(alignedPtr - new_pInMemoryBankPtr.ToInt64()); new_pInMemoryBankPtr = new System.IntPtr(alignedPtr); } // Copy the bank's bytes in our new array, at the correct aligned offset. System.Array.Copy(ms_www.bytes, 0, alignedBytes, alignedOffset, ms_www.bytes.Length); ms_pInMemoryBankPtr = new_pInMemoryBankPtr; ms_pinnedArray.Free(); ms_pinnedArray = new_pinnedArray; } } catch { yield break; } var result = AkSoundEngine.LoadBank(ms_pInMemoryBankPtr, in_uInMemoryBankSize, out ms_bankID); if (result != AKRESULT.AK_Success) { UnityEngine.Debug.LogError("WwiseUnity: AkMemBankLoader: bank loading failed with result " + result); } }
/// <summary>Deletes this bitmap's byte buffer and resets the pixel width and height to zero.</summary> /// <remarks>It is okay to call this method if the bitmap has already been released.</remarks> public void ReleaseByteBuffer() { try { if (fByteBufferHandle.IsAllocated) { fByteBufferHandle.Free(); } } catch (Exception) { } }
public static void Clear() { if (gcHandles != null) { foreach (PTR p in gcHandles) { System.Runtime.InteropServices.GCHandle h = System.Runtime.InteropServices.GCHandle.FromIntPtr((System.IntPtr)p); h.Free(); } } gcHandles = null; }
private void getFileInfo(string myFile) { //Initilaizing MediaInfo MediaInfo MI = new MediaInfo(); //From: preparing an example file for reading FileStream From = new FileStream(myFile, FileMode.Open, FileAccess.Read); //From: preparing a memory buffer for reading byte[] From_Buffer = new byte[64 * 1024]; int From_Buffer_Size; //The size of the read file buffer //Preparing to fill MediaInfo with a buffer MI.Open_Buffer_Init(From.Length, 0); //The parsing loop do { //Reading data somewhere, do what you want for this. From_Buffer_Size = From.Read(From_Buffer, 0, 64 * 1024); //Sending the buffer to MediaInfo System.Runtime.InteropServices.GCHandle GC = System.Runtime.InteropServices.GCHandle.Alloc(From_Buffer, System.Runtime.InteropServices.GCHandleType.Pinned); IntPtr From_Buffer_IntPtr = GC.AddrOfPinnedObject(); Status Result = (Status)MI.Open_Buffer_Continue(From_Buffer_IntPtr, (IntPtr)From_Buffer_Size); GC.Free(); if ((Result & Status.Finalized) == Status.Finalized) { break; } //Testing if MediaInfo request to go elsewhere if (MI.Open_Buffer_Continue_GoTo_Get() != -1) { Int64 Position = From.Seek(MI.Open_Buffer_Continue_GoTo_Get(), SeekOrigin.Begin); //Position the file MI.Open_Buffer_Init(From.Length, Position); //Informing MediaInfo we have seek } }while (From_Buffer_Size > 0); //Finalizing MI.Open_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work //Get() example string itemWidth = MI.Get(StreamKind.Video, 0, "Width"); string itemHeight = MI.Get(StreamKind.Video, 0, "Height"); string itemFormat = MI.Get(StreamKind.Video, 0, "Format"); string itemAudFormat = MI.Get(StreamKind.Audio, 0, "Format"); string itemAudChans = MI.Get(StreamKind.Audio, 0, "Channels"); string myOutpt = itemWidth + "\r\n" + itemHeight + "\r\n" + itemFormat + "\r\n" + itemAudFormat + "\r\n" + itemAudChans + "\r\n";; richTextBox1.Text = myOutpt; }
protected virtual void DisposeRaw() { if (_Stream != null) { _Stream.Dispose(); _Stream = null; } if (_Buffer != null) { _BufferHandle.Free(); _Buffer = null; } }
private void __EventCleanup() { { Microsoft_Kinect_Face_CaptureStatusChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Microsoft_Kinect_Face_CaptureStatusChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Microsoft_Kinect_Face_FaceModelBuilder_add_CaptureStatusChanged(_pNative, Microsoft_Kinect_Face_CaptureStatusChangedEventArgs_Delegate_Handler, true); } _Microsoft_Kinect_Face_CaptureStatusChangedEventArgs_Delegate_Handle.Free(); } } } { Microsoft_Kinect_Face_CollectionStatusChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Microsoft_Kinect_Face_CollectionStatusChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Microsoft_Kinect_Face_FaceModelBuilder_add_CollectionStatusChanged(_pNative, Microsoft_Kinect_Face_CollectionStatusChangedEventArgs_Delegate_Handler, true); } _Microsoft_Kinect_Face_CollectionStatusChangedEventArgs_Delegate_Handle.Free(); } } } { Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; lock (callbackList) { if (callbackList.Count > 0) { callbackList.Clear(); if (_pNative != RootSystem.IntPtr.Zero) { Microsoft_Kinect_Face_FaceModelBuilder_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); } _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); } } } }