-
Notifications
You must be signed in to change notification settings - Fork 1k
Handle ThreadContext cache more cleanly #13530
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
Conversation
Switch to a concurrent backing collection. Note that we only ever create them if you ask for them on the current thread.
There was a problem hiding this 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 improves thread-safety by switching from a Dictionary with manual locking to a ConcurrentDictionary in the ThreadContext cache.
- Replace manual locking with concurrent operations for thread context management.
- Remove unnecessary locks in DisposeInternal, ExitApplication, and Create methods as the backing collection is now thread-safe.
src/System.Windows.Forms/System/Windows/Forms/Application.ThreadContext.cs
Show resolved
Hide resolved
src/System.Windows.Forms/System/Windows/Forms/Application.ThreadContext.cs
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13530 +/- ##
===================================================
+ Coverage 76.59478% 76.59963% +0.00485%
===================================================
Files 3230 3230
Lines 639165 639148 -17
Branches 47297 47295 -2
===================================================
+ Hits 489567 489585 +18
+ Misses 146015 145987 -28
+ Partials 3583 3576 -7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
src/System.Windows.Forms/System/Windows/Forms/Application.ThreadContext.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, too.
Switch to a concurrent backing collection. Note that we only ever create them if you ask for them on the current thread.
Microsoft Reviewers: Open in CodeFlow