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.
use Application.Exit();
For WPF: Application.Current.Shutdown();
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.