private void StopSensor() { if (sensorDevice != null) { sensorDevice.CompositeFrameAvailable -= new CompositeFrameAvailableEventHandler(device_CompositeFrameAvailable); sensorDevice.Shutdown(); sensorDevice = null; } }