Reputation: 7569
I've got the following code in a window B that is started in its own thread from a window A.
view.Closing += (sender, e) =>
{
view.Visibility = Visibility.Collapsed;
e.Cancel = true;
};
When I close window A window B remains in memory and the application doesn't dispose. How should I go forward make sure that the application is shut down when closing window A.
edit: the window B takes a while to load and build that's why the code is there.
Upvotes: 1
Views: 2025
Reputation: 273189
Basic solution: Window A needs to keep a ref to Window B and Dispose() it.
You may have to make the Cancel logic in B conditional.
Upvotes: 2