04-08-2025, 05:31 PM
I can reproduce the problems with changing monitors on Windows 11.
Similar errors appeared in the past, but they were fixed by using the Microsoft.Win32.SystemEvents.DisplaySettingsChanging and Microsoft.Win32.SystemEvents.DisplaySettingsChanged events - in the event handler the code disposes the current D3DImage and also checks if the primary device is changed.
I have testes this on Windows 10 and this still works.
But on Windows 11, when I change the display from the external monitor to the primary monitor (on laptop), I get both events but still the application crashes with UCEERR_RENDERTHREADFAILURE error (WPF render thread crash). Even worse is when I change the display from the primary monitor to the external display. In this case the app just freezes without any exception even before any of the previously mentioned events happen.
I will try to provide the solution for the first case (in case when I get the events). I am not sure what to do in case when the app is not notified on the display change.
It seems that there are some internal changes from Window 10 to Windows 11 that break this. Hopefully I will be able to solve at least some of the cases.
Similar errors appeared in the past, but they were fixed by using the Microsoft.Win32.SystemEvents.DisplaySettingsChanging and Microsoft.Win32.SystemEvents.DisplaySettingsChanged events - in the event handler the code disposes the current D3DImage and also checks if the primary device is changed.
I have testes this on Windows 10 and this still works.
But on Windows 11, when I change the display from the external monitor to the primary monitor (on laptop), I get both events but still the application crashes with UCEERR_RENDERTHREADFAILURE error (WPF render thread crash). Even worse is when I change the display from the primary monitor to the external display. In this case the app just freezes without any exception even before any of the previously mentioned events happen.
I will try to provide the solution for the first case (in case when I get the events). I am not sure what to do in case when the app is not notified on the display change.
It seems that there are some internal changes from Window 10 to Windows 11 that break this. Hopefully I will be able to solve at least some of the cases.
Andrej Benedik