private void JoystickViewer_FormClosed(object sender, FormClosedEventArgs e) { // dispose of GDI resources jsOn.Dispose(); jsOn = null; jsOff.Dispose(); jsOff = null; crosshairs.Dispose(); crosshairs = null; menuFont.Dispose(); // tell the background thread to terminate done = true; // dispose of the device object dev.Dispose(); }