I have an application, where a create a new window for my graphic. I create it next way:
var thread = new Thread(() =>
{
var win = new MyWindow();
win.Show();
Dispatcher.Run();
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
The problem is, that when I close Main application, additional window is still on and I need to close it manually. I set ShutDownMode in my App.xaml
to OnMainWindowClose
and overrided OnClosed
:
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
Application.Current.Shutdown();
}
But it does not help me.