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

fix exception when disposing Ft232h device with SPI manager initialized #2270

Conversation

jb1685
Copy link
Contributor

@jb1685 jb1685 commented Jan 23, 2024

Summary of problem:
When I initialize the Ft232h as a SPI device and then dispose of it, an InvalidOperationException error is thrown because we are disposing of the same elements from the list that we are iterating over.

Resolution:
Make a copy of the "_managers" list by using "ToList" so that the iteration continues as we dispose from the target list

Example:
image
Path: /Users/joshbender/DocumentsLocal/Github/iot/src/devices/Ft232H/samples/Program.cs

image
Path: /Users/joshbender/DocumentsLocal/Github/iot/src/devices/Board/Board.cs
Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Jan 23, 2024
@jb1685
Copy link
Contributor Author

jb1685 commented Jan 23, 2024

@dotnet-policy-service agree

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Looks good,

@pgrawehr
Copy link
Contributor

/azp run dotnet.iot

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pgrawehr pgrawehr merged commit c70264f into dotnet:main Jan 28, 2024
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants