protected override void OnDestroy() { base.OnDestroy(); if (reader != null) { // unregister barcode event listener reader.RemoveBarcodeListener(this); // unregister trigger state change listener reader.RemoveTriggerListener(this); // close BarcodeReader to clean up resources. // once closed, the object can no longer be used. reader.Close(); } if (manager != null) { // close AidcManager to disconnect from the scanner service. // once closed, the object can no longer be used. manager.Close(); } }