Call to ParkingWindow.RemoveReflectChild() causes Cross-thread exception under load
See original GitHub issue- .NET Core Version:
Version: 5.0.0-alpha.1.20072.3
- Have you experienced this same bug with .NET Framework?: No
Problem description:
Call to ParkingWindow.RemoveReflectChild() causes Cross-thread exception under load
Expected behavior: There should be no error when GC frees the resources.
Minimal repro: Run WinForms app under load and trigger GC to free resources.
System.InvalidOperationException: 'Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.'
> System.Windows.Forms.dll!System.Windows.Forms.Control.Handle.get() Line 2502 C#
System.Windows.Forms.Primitives.dll!Interop.User32.GetWindowThreadProcessId(IHandle hWnd, out uint lpdwProcessId) Line 17 C#
System.Windows.Forms.dll!System.Windows.Forms.Application.ParkingWindow.RemoveReflectChild() Line 81 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.ReflectParent.set(System.Windows.Forms.Control value) Line 3137 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.UpdateReflectParent(bool findNewParent) Line 11630 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.Dispose(bool disposing) Line 5188 C#
System.ComponentModel.Primitives.dll!System.ComponentModel.Component.~Component() Line 22 C#
[Native to Managed Transition]
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Cross-thread operation not valid: Control accessed from a ...
Control from different thread than UI thread will cause cross-thread exception. Since there is only one thread, all UI operations are queued ...
Read more >How to make thread-safe calls to controls - Windows Forms ...
Control accessed from a thread other than the thread it was created on. The InvalidOperationException always occurs for unsafe cross-thread ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

PR #2304 changed more calls in the same way, no idea how many of those can cause regressions though.
I checked v3.x are unaffected, which is good.