private static void KinectStatusThread( )
{
while ( !stopEvent.WaitOne( 100, false ) )
{
lock ( openDevices )
{
if ( openDevices.Count != 0 )
{
// update the status for each open device
foreach ( DeviceContext deviceContext in openDevices.Values )
{
if ( deviceContext.DeviceFailed )
{
continue;
}
if ( KinectNative.freenect_update_tilt_state( deviceContext.Device ) < 0 )
{
deviceContext.DeviceFailed = true;
deviceContext.FireFailureHandlers( );
}
else
{
// get updated device status
IntPtr ptr = KinectNative.freenect_get_tilt_state( deviceContext.Device );
deviceContext.TiltState = (KinectNative.TiltState)
System.Runtime.InteropServices.Marshal.PtrToStructure( ptr, typeof( KinectNative.TiltState ) );
}
}
}
}
// let the kinect library handle any pending stuff on the usb stream
KinectNative.freenect_process_events_timeout0( KinectNative.Context );
}
}