Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

wpf

rdp

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?

like image 296
Coder14 Avatar asked Dec 03 '15 08:12

Coder14


2 Answers

I don't know why this happens, but with some code from this page: Optimizing Visual Studio 2010 and WPF applications for Remote Desktop I think that you can understand if (Un)Loaded is triggered by Remote Desktop.

like image 67
Giangregorio Avatar answered Nov 13 '22 16:11

Giangregorio


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

like image 43
Coder14 Avatar answered Nov 13 '22 15:11

Coder14