WPF: Prevent unload & load after RDP (dis)connect

折月煮酒 提交于 2019-12-28 07:03:31

问题


When my WPF application is open, and I open a Remote Desktop Connect to my PC, WPF reloads the application (Unload and Load events on the main control are triggered). When I disconnect, this happens again.

I understand that the UI has to be redrawn, but why is the control reloaded? Can this be prevented? Or is there a way to detect if a reload is triggered by an RDP (dis)connect?


回答1:


Interesting question, i don't know why this happens, but with some code from this page http://blogs.msdn.com/b/jgoldb/archive/2010/02/27/optimizing-visual-studio-2010-and-wpf-applications-for-remote-desktop.aspx I think that you can understand if a (Un)Loaded is triggered by Remote Desktop.




回答2:


I could fix the problems with my application by unsubscribing the Load-event at first execution and move deinit code from the Unloaded-event to the Exit-event.



来源:https://stackoverflow.com/questions/34061226/wpf-prevent-unload-load-after-rdp-disconnect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!