private void SensorAllFramesReady(object sender, AllFramesReadyEventArgs e) { // in the middle of shutting down, or lingering events from previous sensor, do nothing here. if (null == this.sensorChooser || null == this.sensorChooser.Kinect || this.sensorChooser.Kinect != sender) { return; } try { using (var depthFrame = e.OpenDepthImageFrame()) { if (null != depthFrame) { this.colorStream.ProcessDepth(depthFrame.GetRawPixelData(), depthFrame.Timestamp); this.interactionStream.ProcessDepth(depthFrame.GetRawPixelData(), depthFrame.Timestamp); } } using (var colorFrame = e.OpenColorImageFrame()) { if (null != colorFrame) { this.colorStream.ProcessColor(colorFrame.GetRawPixelData(), colorFrame.Timestamp); } } using (var skeletonFrame = e.OpenSkeletonFrame()) { if (null != skeletonFrame) { skeletonFrame.CopySkeletonDataTo(this.skeletons); this.colorStream.ProcessSkeleton(this.skeletons, skeletonFrame.Timestamp); this.interactionStream.ProcessSkeleton(this.skeletons, this.sensorChooser.Kinect.AccelerometerGetCurrentReading(), skeletonFrame.Timestamp); this.controller.processSkeletons(this.skeletons, skeletonFrame.Timestamp); } } var skeleton = skeletons.FirstOrDefault(x => x != null && x.TrackingState == SkeletonTrackingState.Tracked); if (skeleton != null) { colorStream.SetTrackedPlayer(skeleton.TrackingId); } } catch (InvalidOperationException) { // Ignore the exception. } }