Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly close an instance of CustomDevice ? #1373

Open
DSanchen opened this issue Dec 1, 2022 · 0 comments
Open

How to properly close an instance of CustomDevice ? #1373

DSanchen opened this issue Dec 1, 2022 · 0 comments
Labels

Comments

@DSanchen
Copy link

DSanchen commented Dec 1, 2022

Which sample are you reporting a bug in?

Example: Custom Capability

Describe the bug
Scenario2_DeviceConnect.xaml.cs includes the function private void CloseFx2Device().
This function does not really close the device. It sends a notification to the user and then calls the ClearSelectedDevice() function of the DeviceList-singleton, which in turn calls SetSelectedDevice(null, null). Doing so triggers the DeviceClosing-Event (to which, as far as I can see nobody is attached) and sets some members to null. There is no code that closes the Device.

Subsequent tries to open the same device fail with an AccessDeniedExeption.

To Reproduce

var device = await CustomDevice.FromIdAsync(Id, DeviceAccessMode.ReadWrite, DeviceSharingMode.Exclusive);
device = null;
device = await CustomDevice.FromIdAsync(Id, DeviceAccessMode.ReadWrite, DeviceSharingMode.Exclusive);
this will throw an Exception

Expected behavior
The function CloseFx2Device() should somehow close the device. As CustomDevice itself does not provide such functionality, I suppose there should be some other mechanism to close the device.

@DSanchen DSanchen added the bug label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant