public void CollectFaceDataAsync(RootSystem.Action <Microsoft.Kinect.Face.FaceModelData> success, RootSystem.Action <int> failure) { if (_pNative == RootSystem.IntPtr.Zero) { throw new RootSystem.ObjectDisposedException("FaceModelBuilder"); } RootSystem.Guid g = RootSystem.Guid.NewGuid(); if (success != null) { Microsoft_Kinect_Face_FaceModelData_Delegate_SuccessCallbacks.Add(g.ToString(), success); } if (failure != null) { ErrorCallbacks.Add(g.ToString(), failure); } Microsoft_Kinect_Face_FaceModelBuilder_CollectFaceDataAsync_Indexed(_pNative, CollectAsyncSuccessDelegate, CollectAsyncFailureDelegate, g.ToString()); Helper.ExceptionHelper.CheckLastError(); }
private static void Microsoft_Kinect_Face_FaceModelData_Delegate_Success(RootSystem.IntPtr result, string guid) { List <Helper.SmartGCHandle> pins; if (PinnedObjects.TryGetValue(guid, out pins)) { foreach (var pin in pins) { pin.Dispose(); } PinnedObjects.Remove(guid); } RootSystem.Action <Microsoft.Kinect.Face.FaceModelData> callback = null; if (Microsoft_Kinect_Face_FaceModelData_Delegate_SuccessCallbacks.TryGetValue(guid, out callback)) { var faceModelData = Helper.NativeObjectCache.CreateOrGetObject <Microsoft.Kinect.Face.FaceModelData>(result, n => new Microsoft.Kinect.Face.FaceModelData(n)); Helper.EventPump.Instance.Enqueue(() => callback(faceModelData)); } ErrorCallbacks.Remove(guid); Microsoft_Kinect_Face_FaceModelData_Delegate_SuccessCallbacks.Remove(guid); }