Say I have a WPF application with a button. In the buttom click event, I created a System.Windows.Window instance. For some reason, I forgot to call window.ShowDialog() and leave there. When my main application starts, then clicked on the button, nothing happens of cause. But when I want to exit this application, the main window closed, but the process is still running. I’m not sure why causes this behavior. It’s easy to be fixed, but does anyone know
Share
I imagine it’s because the default for
Application.ShutdownModeisShutdownMode.OnLastWindowClose. If you set it toShutdownMode.OnMainWindowCloseit should exit immediately after you close the main window.