When running software that includes clipboard monitoring features, all WPF applications on the computer may become extremely slow when performing clipboard copy operations. Meanwhile, other programs such as Winform applications, browsers, and Windows Notepad operate normally.
Symptoms: When selecting "Copy" (or "Cut") from the right-click menu in any text box, it takes 0.5 to 1 second for the menu to close.
Description
When running software that includes clipboard monitoring features, all WPF applications on the computer may become extremely slow when performing clipboard copy operations. Meanwhile, other programs such as Winform applications, browsers, and Windows Notepad operate normally. Symptoms: When selecting "Copy" (or "Cut") from the right-click menu in any text box, it takes 0.5 to 1 second for the menu to close.
https://github.com/dotnet/wpf/assets/1972649/8b74c764-2aa2-4d9a-ad00-30c9571fd256
Compared to winform application:
https://github.com/dotnet/wpf/assets/1972649/602add4b-9f90-490d-8fa5-c7597793ea73
Reproduction Steps
TestClipboard.zip
https://github.com/dotnet/wpf/assets/1972649/ad11f4b4-9542-4641-80b4-27f7e657e871
Expected behavior
Copy operation should complete immediately.
Actual behavior
Copy will complete with big delay and UI freeze.
Regression?
This problem exists for a long time, both .NET framework and .Net8.
Known Workarounds
No workgorund.
Impact
Very bad user experience.
Configuration
No response
Other information
Time was costed in System.Windows.Clipboard.CriticalSetDataObject, It fails to olesetclipboard and retry many times with Sleep().