await GetKinect in FluentKinect


Today's project by Marcus Kohnert brings us back to the FluentKinect and Marcus' recent update to make it awaitable...

await GetKinect()

In the first blog post about FluentKinect I’ve mentioned that I’m not very happy with the actual process of getting a KinectSensor instance from the KinectSensors collection.

FluentKinect has now been updated and the KinectConnector’s static method GetKinect is now awaitable.

var kinect = await KinectConnector.GetKinect();


It’s not thread safe at the moment but there are a few improvements now in my opinion.

    • You can start and debug your actual program without a Kinect controller connected because no more exception is thrown. This helps with Kinect programming on a plane for example. <img src='' alt='Wink' />
    • Your program starts faster because GetKinect returns immediately
    • Since GetKinect returns a Task you get the ability to await the result

Project Information URL:

Project Download URL:

Project Source URL:

public static Task<KinectSensor> GetKinect()
    return Task.Factory.StartNew<KinectSensor>(() =>
        if (kinectSensor != null) return kinectSensor;

        var kinect = KinectSensor.KinectSensors
                            .FirstOrDefault(_ => _.Status == KinectStatus.Connected);
        if (kinect != null)
            kinectSensor = kinect;
            return kinectSensor;

        using (var signal = new ManualResetEventSlim())
            KinectSensor.KinectSensors.StatusChanged += (s, e) =>
                if (e.Status == KinectStatus.Connected)
                    kinectSensor = e.Sensor;
                    coordinateMapper = new CoordinateMapper(kinectSensor);


        return kinectSensor;

Contact Information: