I am working on an application that generally runs 24x7. It does so well for a period of time but I have noticed that after the DisplaySettingsChanging event fires (via an RDP connection) the application will continue to process in the background but the UI becomes completely unusable. It does not tell you in the task manager that the application is unresponsive like when the UI message pump is blocked. I know there is a bug with the SystemEvents class (still in .NET 4?). I have moved our splash screen into the form load event handler and do not create any controls on another thread other than the main UI thread. I have tried subscribing to the following events in the constructor of my main form (which has a valid SynchronizationContext)
SystemEvents.DisplaySettingsChanging
SystemEvents.DisplaySettingsChanged
SystemEvents.UserPreferencesChanged
but per this related solution but it doesn't seem to help.
What else am I missing here?
EDIT 1: Ok after running spy++ I see there are two threads that own windows other than the main UI thread. However when I examine the threads within my process in visual studio I don't see either one. Does that mean some referenced assembly is the culprit? Probably should be a separate question, but how do I find out?
EDIT 2: The second window is a button click event that opens an open file dialog box. I checked the apartment state for that thread and it is correct STA. I have not determined how or when that other thread is created. Seems like it must be the offender.