@Override
    public void run() {
      while (loaded) {
        HANDLE[] handles = {nextSkeletonFrame, nextDepthImageFrame, nextInteractionFrame};

        Kernel32.INSTANCE.WaitForMultipleObjects(handles.length, handles, false, Kernel32.INFINITE);

        if (WinBase.WAIT_OBJECT_0 == Kernel32.INSTANCE.WaitForSingleObject(nextSkeletonFrame, 0))
          try {
            processSkeleton();
          } catch (Throwable t) {
            System.out.println("Error in processSkeleton");
          }

        if (WinBase.WAIT_OBJECT_0 == Kernel32.INSTANCE.WaitForSingleObject(nextDepthImageFrame, 0))
          try {
            processDepth();
          } catch (Throwable t) {
            System.out.println("Error in processDepth");
          }

        if (WinBase.WAIT_OBJECT_0 == Kernel32.INSTANCE.WaitForSingleObject(nextInteractionFrame, 0))
          try {
            processInteraction();
          } catch (Throwable t) {
            System.out.println("Error in processInteraction");
          }
      }
    }
  @Override
  public ByteBuffer getVisualData() {
    Kernel32.INSTANCE.WaitForSingleObject(nextColorImageFrame, Kernel32.INFINITE);
    NUI_IMAGE_FRAME imageFrame = new NUI_IMAGE_FRAME();
    checkRC(device.NuiImageStreamGetNextFrame(colorStream, new DWORD(0), imageFrame));
    NUI_LOCKED_RECT lockedRect = new NUI_LOCKED_RECT();
    checkRC(imageFrame.pFrameTexture.LockRect(new UINT(0), lockedRect, null, new DWORD(0)));

    if (lockedRect.Pitch == 0) throw new RuntimeException("Kinect didn't give us data");

    ByteBuffer buf = ByteBuffer.wrap(lockedRect.getBytes());
    checkRC(imageFrame.pFrameTexture.UnlockRect(0));

    // Release the frame
    checkRC(device.NuiImageStreamReleaseFrame(colorStream, imageFrame));

    return buf;
  }