This is more compact

1
2
3
4
5
6
7
8
9
10
       private int GetTotalSkeleton(AllFramesReadyEventArgs e)
       {
           using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
           {
               if (skeletonFrameData == null) return 0;
               skeletonFrameData.CopySkeletonDataTo(allSkeletons);
               return  allSkeletons.Count(s => s.TrackingState != SkeletonTrackingState.NotTracked);
           }
       }