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 how we update the properties in environments page after an operation #2950

Merged
merged 3 commits into from
May 17, 2024

Conversation

bbonaby
Copy link
Contributor

@bbonaby bbonaby commented May 16, 2024

Summary of the pull request

This issue doesn't happen often but it is still an issue that can crash Dev Home which I observed. See: #2947

I explained the issue in point 1 in this PR: #2892

Basically, when you perform any action in the environments page, e.g Starting/Stopping the properties are updated because they may have changed as a result of the operation. In the issue I how the exception that can happen when we attempt to remove the old items from the observable collection. But because we go on add items to the collection afterwards we get an exception. As a minimal change I'm moving the loop that add new items to the observable collection to the try/catch. And then if there is an exception create a new observable collection with the new items. This will least allow the user to see the updated properties.

In the future I'd like to investigate why the observable collection is throwing but for build we can do this work around

References and relevant issues

Detailed description of the pull request / Additional comments

Validation steps performed

PR checklist

@bbonaby bbonaby marked this pull request as ready for review May 16, 2024 21:31
{
collectionToUpdate.Add(listWithUpdates[i]);
}

Copy link
Member

Choose a reason for hiding this comment

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

These loops fire OnCollectionChanged events for every operation which is inefficient and can make UX less responsive.
There is BulkObservableCollection class that has AddRange method and
BeginBulkOperation and EndBulkOperation methods that can be used to suspend notification while doing multiple changes to the collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using that requires adding the Microsoft.VisualStudio.Language.Intellisense nuget package so I don't think we want to add it this close to cut off. Luckily the amount of properties sent back by both the Hyper-V extension and Dev Box are small (4 for dev box and 5 for hyper-V). So I can investigate using the above nuget package after build

@bbonaby bbonaby merged commit 5e500fb into main May 17, 2024
4 checks passed
EricJohnson327 pushed a commit that referenced this pull request May 17, 2024
…ion (#2950)

* update how we update the properties

* fix ordering

* update based on comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dev Home can randomly crash when updating properties on Environments page
4 participants