public void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { if (!IsRecording) { return; } lock (RecordStream) { SkeletonFrame skeletonFrame = e.SkeletonFrame; int iSkeleton = 0; foreach (SkeletonData data in skeletonFrame.Skeletons) { if (SkeletonTrackingState.Tracked == data.TrackingState) { //Recording for longer than a day will cause the timer to roll over. Who would record 24+ hours of Kinect data anyways? TimeSpan elapsedTime = DateTime.Now - StartTime; RecordStream.Write(elapsedTime.Hours.ToString() + ":" + elapsedTime.Minutes.ToString() + ":" + elapsedTime.Seconds.ToString() + ":" + elapsedTime.Milliseconds.ToString() + ","); foreach (Joint joint in data.Joints) { RecordStream.Write(joint.ID.ToString() + "," + (joint.Position.X * 1000).ToString() + "," + (joint.Position.Y * 1000) + "," + (joint.Position.Z * 1000) + ","); } RecordStream.WriteLine(""); } iSkeleton++; } // for each skeleton } }