Skip to content

Conversation

@JonasUJ
Copy link

@JonasUJ JonasUJ commented Dec 16, 2025

Description of Change

UnpackagedPreferencesImplementation on Windows does not lock file I/O. Setting preferences from multiple threads sometimes causes an IOException stating that the file is used by another process. The solution is to put a lock in Load and Save

I'm going on holiday until mid-Jan and won't respond to comments quickly meanwhile.

Issues Fixed

Fixes #27167

Copilot AI review requested due to automatic review settings December 16, 2025 13:57
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 16, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@JonasUJ! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@JonasUJ
Copy link
Author

JonasUJ commented Dec 16, 2025

@dotnet-policy-service agree

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds thread-safe file I/O locking to the UnpackagedPreferencesImplementation class on Windows to prevent IOException when preferences are accessed from multiple threads concurrently.

Key Changes

  • Introduces a static locker object for synchronization
  • Wraps the Load() method's file operations in a lock block
  • Wraps the Save() method's file operations in a lock block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent Problem with Preferences on Windows

1 participant