Here is my problem:
In my WPF application I have a MyBaseControl
(derives from System.Windows.Controls.ContentControls
) and a lot of MyCustomControls
which derives from MyBaseControl
. I need to do some storing and cleanup operations for all my MyCustomControls
befor the application is closed.
Here is some code:
public abstract class MyBaseControl : ContentControl
{
// Do some smart stuff.
}
App.Exit += new System.Windows.ExitEventHandler(App.App_OnExit);
In App_OnExit()
I do the really last operations that need to be done.
I tried to do my cleanup operations in the destructor of MyBaseControl
but this is called after App_OnExit()
. Same problem with AppDomain.CurrentDomain.ProcessExit
.
The ContentControl.Closed
and ContentControl.Unloaded
events don't occour when I exit the application via ALT+F4.
Where can I hook in to do my cleanup operations?