I initialazed DeviceWatcher ... works fine, I add Honeywell Ring Scanner it raises event deviceWatcher. When I remove Honeywell USB Ring Scanner it raises event DeviceWatcher_Removed
where I null ClaimedBarcodeScanner
and BarcodeScanner
object and DeviceWatcher
_Updated where return status was STOP
After I connect Ring Scanner nothing happened in App. If I restart the app it's work until I disconnect and connect Ring Scanner.
I need to release BrcodeScanner
from app.
I try on Honeywell D75e Win 10 iot
and Honeywell Ring Scanner 8620903
I also try free memory ...
GC.Collect();
GC.WaitForPendingFinalizers();
I try to do Dispose of ClaimedBarcodeScanner
When you disconnect the device, it will raise the device removed event, but all pending operations need to be canceled properly, and all of the resources need to clean up. Please refer to following code in EventHandlerForDevice. The callback in the code is used to close the device explicitly is to clean up resources, to properly handle errors,and stop talking to the disconnected device.
private async void CloseCurrentlyConnectedDevice()
{
if (device != null)
{
// Notify callback that we're about to close the device
if (deviceCloseCallback != null)
{
deviceCloseCallback(this, deviceInformation);
}
// This closes the handle to the device
device.Dispose();
device = null;
}
}