private void Shutdown() { if (m_sensor != null) { // detach event handlers m_sensor.TouchDown -= SensorTouchDown; m_sensor.TouchMove -= SensorTouchMove; m_sensor.TouchUp -= SensorTouchUp; // stop the sensor m_sensor.Stop(); } if (m_audioDevice != null) { m_audioDevice.Dispose(); m_audioDevice = null; } Thread.Sleep(20); }